why showing this error in codeblocks? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why showing this error in codeblocks?

||=== Build: Debug in Composition (compiler: GNU GCC Compiler) ===| C:\Users\noman\Desktop\My C++ codes for learning\Composition\Birthday.cpp|3|error: redefinition of 'Birthday::Birthday(int, int, int)'| C:\Users\noman\Desktop\My C++ codes for learning\Composition\Birthday.h|9|note: 'Birthday::Birthday(int, int, int)' previously defined here| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

24th May 2019, 9:05 AM
Abdullah Al Noman
Abdullah Al Noman - avatar
1 Answer
+ 1
It says that you're re-defining the definition of a constructor. You could be doing this. class A() { public: A(int m, int d, int y); }; A::A(int m, int d, int y) { // some code } // here your redefining it again // this is causing the error. A::A(int m, int d, int y) { // some code } if you're trying to overload then you should remember that there has to be a change in the type of params or in the number of params. or the methods be declared as constant and non-constant.
24th May 2019, 9:12 AM
Farry
Farry - avatar