i am getting a redefinition error when i write exactly this code.Why? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

i am getting a redefinition error when i write exactly this code.Why?

redefinition class error

26th Jun 2018, 5:57 PM
Nurullah Kuş
Nurullah Kuş - avatar
24 ответов
+ 3
which programming language
26th Jun 2018, 5:59 PM
Agent
Agent - avatar
+ 3
post the code
26th Jun 2018, 6:01 PM
Max
Max - avatar
+ 2
Nurullah Kuş thats the include guard i was talking about, it prevents stuff from being included multiple times in indirect ways and therefore prevents redefinition errors
26th Jun 2018, 7:51 PM
Max
Max - avatar
+ 1
Nurullah Kuş seems to work
26th Jun 2018, 6:04 PM
Max
Max - avatar
+ 1
works for me
26th Jun 2018, 6:06 PM
Agent
Agent - avatar
+ 1
did you use include guards?
26th Jun 2018, 6:06 PM
Max
Max - avatar
+ 1
for your header files? or what header files did you make?
26th Jun 2018, 6:07 PM
Max
Max - avatar
+ 1
can you post the content of each file?or post a screenshot somwhere and link it
26th Jun 2018, 6:08 PM
Max
Max - avatar
+ 1
and you included the one for birthday in the one for person and included both in the main file?
26th Jun 2018, 6:09 PM
Max
Max - avatar
+ 1
Nurullah Kuş there don‘t seem to be include guards, https://en.m.wikipedia.org/wiki/Include_guard try adding them you might also need to use: using namespace std; in Person.h
26th Jun 2018, 7:29 PM
Max
Max - avatar
26th Jun 2018, 7:47 PM
Max
Max - avatar
0
https://code.sololearn.com/cOrP2BbgJj4r/?ref=app
26th Jun 2018, 6:04 PM
Nurullah Kuş
Nurullah Kuş - avatar
0
i made two different header files and one cpp file in dev c++
26th Jun 2018, 6:05 PM
Nurullah Kuş
Nurullah Kuş - avatar
0
wrote same code exactly to dev c++
26th Jun 2018, 6:06 PM
Nurullah Kuş
Nurullah Kuş - avatar
0
yes i did
26th Jun 2018, 6:07 PM
Nurullah Kuş
Nurullah Kuş - avatar
0
i did two different header file for Birthday and person
26th Jun 2018, 6:08 PM
Nurullah Kuş
Nurullah Kuş - avatar
0
yes added both in main,gonna send the photo now
26th Jun 2018, 6:10 PM
Nurullah Kuş
Nurullah Kuş - avatar
26th Jun 2018, 7:12 PM
Nurullah Kuş
Nurullah Kuş - avatar
0
couldnt upload photo but i write exactly like this,check inside code i added header file like this
26th Jun 2018, 7:14 PM
Nurullah Kuş
Nurullah Kuş - avatar
0
first one Birthday class second one Person class and last one main cpp,
26th Jun 2018, 7:16 PM
Nurullah Kuş
Nurullah Kuş - avatar