473,857 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C:\KrugiKorobki .cpp|55|error: invalid operands of types `int' and `double' to binary

1 New Member
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<TX/graphics.h>
  3. #include<time.h>
  4. // I need help!
  5. struct Krug{
  6.         double _x;
  7.         double _y;
  8.         double _skox;
  9.         double _skoy;
  10.         double _granx1;
  11.         double _grany1;
  12.         double _granx2;
  13.         double _grany2;
  14.         int _rad;
  15.         void init(double x,double y,double skox,double skoy,int rad,double granx1,double grany1,double granx2,double grany2);
  16.         void draw();
  17.         void dvig();
  18.     };
  19. struct Korobka{
  20.     double _granx1;
  21.     double _grany1;
  22.     double _granx2;
  23.     double _grany2;
  24.     int _kolvoprim;
  25.     Krug Circles[300];
  26.     void init(double granx1,double grany1,int granx2,int grany2,int kolvoprim);
  27.     void draw();
  28.     void start();
  29. };
  30. int main(){
  31.     txCreateWindow(1025,769);
  32.     txSetFillColor(txBLACK);
  33.     Korobka Yaschik;
  34.     Yaschik.init(100,100,801,601,5);
  35.     Yaschik.draw();
  36.     Yaschik.start();
  37.     return 0;
  38. }
  39. void Krug::init(double x,double y,double skox,double skoy,int rad,double granx1,double grany1,double granx2,double grany2){
  40.     _granx1=granx1;
  41.     _grany1=grany1;
  42.     _granx2=granx2;
  43.     _grany2=grany2;
  44.     _x=x;
  45.     _y=y;
  46.     _skox=skox;
  47.     _skoy=skoy;
  48.     _rad=rad;
  49. }
  50. void Korobka::init(double granx1,double grany1,int granx2,int grany2,int kolvoprim){
  51.     srand(time(0));
  52.     _granx1=granx1;
  53.     _grany1=grany1;
  54.     _granx2=granx2;
  55.     _grany2=grany2;
  56.     int rx=rand()%_granx2+_granx1;
  57.     int ry=rand()%_grany2+_grany1;
  58.     _kolvoprim=rand()%(kolvoprim+1);
  59.     for(int i = 0;i<_kolvoprim;i++){
  60.         Circles[i].init(rx,ry,rand()%10+1,rand()%10+1,rand()%10+5,_granx1,_grany1,_granx2,_grany2);
  61.     }
  63. }
  64. void Korobka::draw(){
  65.     txRectangle(_granx1,_grany1,_granx2,_grany2);
  66. }
  67. void Korobka::start(){
  68.     while(1){
  69.         for(int i = 0;i<_kolvoprim;i++){
  70.             txLock();
  71.             Circles[i].dvig();
  72.             txUnlock();
  73.         }
  74.         txSleep(40);
  75.     }
  76. }
  77. void Krug::draw(){
  78.     txCircle(_x,_y,_rad);
  79. }
  80. void Krug::dvig(){
  81.     txSetColor(txBLACK);
  82.     Krug::draw();
  83.     if((_x+_rad<=_granx1)or(_x+_rad>=_granx2)){
  84.         _skox=-_skox;
  85.         Krug::init(_x+=_skox,_y+=_skoy,_skox,_skoy,_rad,_granx1,_grany1,_granx2,_grany2);
  86.     }
  87.     if((_y+_rad<=_grany1)or(_y+_rad>=_grany2)){
  88.         _skoy=-_skoy;
  89.         Krug::init(_x+=_skox,_y+=_skoy,_skox,_skoy,_rad,_granx1,_grany1,_granx2,_grany2);
  90.     }
  91.     else{
  92.         Krug::init(_x+=_skox,_y+=_skoy,_skox,_skoy,_rad,_granx1,_grany1,_granx2,_grany2);
  93.     }
  94.     txSetColor(txWHITE);
  95.     Krug::draw();
  96. }
Oct 24 '09 #1
2 5813
2,426 Recognized Expert Top Contributor
The error message in your title appears to identify line 55 as the source of the error. Does line 55 of your original source correspond to line 55 in the code you posted?
Oct 24 '09 #2
687 Contributor
You can't use double ( _granx2 ) int modulo operation. ( btw , why
_gran** members are all double, but granx2 argument is int? )
Oct 24 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Bo Peng | last post by:
Dear list, I need to add "disable output" feature to a bunch of objects that output to ostream (or ofstream). The least intrusive way to do this is pass them ofstream("/dev/null") but this makes my program less portable. Is there a null ostream built in cpp? Is it easy to implement one? Thanks. Bo
by: DiskMan | last post by:
System: Redhat 7.2 Kernel- GCC-3.4.3 CCC-6.5.9 Binutils-2.15 Make-3.80 GTK/GLIB-2.6.7 For some reason my Linux box is suddenly having issues trying to read ;
by: muthu | last post by:
In the following code it gives the error "error: invalid operands to binary &" Why it is happening #include <signal.h> #include <errno.h> #define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG) /* <signal.husually defines NSIG to include signal number 0 */
by: Noah Roberts | last post by:
Item #1 in the More Exceptional C++ book uses the following construct: fstream in; .... process( in.is_open() ? in : cin,...); Where process has been shown as having various multiple different
by: John Doe | last post by:
segmentation error !!!! hi guys , i wrote this program to multiply two matrices (just the basic code without checkin 4 the condition n==p ) " #include<stdio.h> main() { int a,b,c; int m,n,p,q,i,j,k;
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are involved. The problem is that comparisons between signed and unsigned values are machine- dependent, because they depend on the sizes of the various integer types. For example, suppose that int is 16 bits
by: subramanian100in | last post by:
consider the following program: #include <iostream> using namespace std; class my_complex { public: friend ostream & operator<<(ostream &os, const my_complex &c);
by: happytoday | last post by:
I compiled that program under turbo C without any problems but with sunstudi I found those errors: "pnt02ma1.c", line 37: warning: implicit function declaration: system "pnt02ma1.c", line 58: operands must have arithmetic type: op "*" "pnt02ma1.c", line 58: assignment type mismatch: pointer to float "=" double "pnt02ma1.c", line 59: operands must have arithmetic type: op "/" "pnt02ma1.c", line 60: operands have incompatible types:...
by: Kapteyn's Star | last post by:
Hi newsgroup The program here given is refused by GCC with a error i cannot understand. It says rnd00.c: In function ‘main’: rnd00.c:26: error: expected expression before ‘]’ token How to make it compile? I also tried buf but that gives "segmentation fault". Thanks in advanced.
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.