Search found 15 matches
- February 1st, 2023, 6:38 pm
- Forum: Everything
- Topic: Having trouble with the PI number
- Replies: 1
- Views: 11466
Re: Having trouble with the PI number
Any answer to this ?
- January 15th, 2023, 10:49 pm
- Forum: Everything
- Topic: Having trouble with the PI number
- Replies: 1
- Views: 11466
Having trouble with the PI number
I my code I include: #define _USE_MATH_DEFINES #include <cmath> when I try to use M_PI (the macro that defines a double M_PI = 3.14....) it says "undefined symbol" or something like that. But when I use: #define _USE_MATH_DEFINES #include <math.h> my code compiles without trouble. The problem is tha...
- January 6th, 2023, 4:37 am
- Forum: Everything
- Topic: why C++ cannot let you initialize a static array of objects that have at least one reference value ?
- Replies: 6
- Views: 15225
Re: why C++ cannot let you initialize a static array of objects that have at least one reference value ?
...story of my life right there
- January 6th, 2023, 3:22 am
- Forum: Everything
- Topic: why C++ cannot let you initialize a static array of objects that have at least one reference value ?
- Replies: 6
- Views: 15225
Re: why C++ cannot let you initialize a static array of objects that have at least one reference value ?
I did that, but I was wondering if there was a more clever way of doing it.
- January 6th, 2023, 12:27 am
- Forum: Everything
- Topic: why C++ cannot let you initialize a static array of objects that have at least one reference value ?
- Replies: 6
- Views: 15225
Re: why C++ cannot let you initialize a static array of objects that have at least one reference value ?
I suspected it could not be done this way. I actually finished the beginner series. I knew about std::vector, is just that this question arose while trying some coding. So, thanks again for the reply !. Ohh, I need some of your wisdom here, i have a code of block and i want to replace all appearance...
- January 5th, 2023, 5:42 pm
- Forum: Everything
- Topic: why C++ cannot let you initialize a static array of objects that have at least one reference value ?
- Replies: 6
- Views: 15225
why C++ cannot let you initialize a static array of objects that have at least one reference value ?
Say I have a class A defined as: #include "Graphics.h" class A { public: A(Graphics& gfx) : gfx(gfx) { } A() = delete; A(const A&) = delete; A& operator = (const A&) = delete private: Graphics& gfx; } ...and then say I want to create a static array of objects of class A in another class B: class B {...
- January 4th, 2023, 2:01 pm
- Forum: Everything
- Topic: Having problems overloading += operator of my Vector structure.
- Replies: 8
- Views: 16032
Re: Having problems overloading += operator of my Vector structure.
Yeah, I have this love-hate relationship with C++. Its whims and tantrums keeps me enough interested to keep learning, and some days I just want to throw the laptop out of the window ! Anyway, thanks for your answers, they were very educational to my. You have my thanks.
- January 4th, 2023, 7:32 am
- Forum: Everything
- Topic: Having problems overloading += operator of my Vector structure.
- Replies: 8
- Views: 16032
Re: Having problems overloading += operator of my Vector structure.
I see...but what about the #pragma once directive ? I though it was there to prevent re-definitions !
- January 4th, 2023, 5:21 am
- Forum: Everything
- Topic: Having problems overloading += operator of my Vector structure.
- Replies: 8
- Views: 16032
Re: Having problems overloading += operator of my Vector structure.
What I did actually was this: 1) Added Vectors.h file in my solution. 2) In that file I defined a struct name "Vector2Float" with its members and functions. 3) Then I needed operators "vector x scalar" and "scalar x vector". 4) The first one you can define it inside the struct because it is an lvalu...
- January 3rd, 2023, 6:12 am
- Forum: Everything
- Topic: Having problems overloading += operator of my Vector structure.
- Replies: 8
- Views: 16032
Re: Having problems overloading += operator of my Vector structure.
Thanks for the answer, it all makes sense now. About the constexpr thing, before I used to put nothing but my compiler complained about the "operator overloading" being redefined in many other files of my project. I fix those errors by placeing "inline" before the return type of the += operator. But...