473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

1
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.     }
  62.  
  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. }
  97.  
Oct 24 '09 #1
2 5741
donbock
2,426 Expert 2GB
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
newb16
687 512MB
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

13
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...
1
by: DiskMan | last post by:
System: Redhat 7.2 Kernel-2.6.11.8 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 ;
4
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) >=...
24
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...
4
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...
7
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...
10
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);
5
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:...
63
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 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

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.