N
Ninan
I am using gcc compiler
gcc B.o Main.o -lMyLib
//A.h
class A {
public:
A();
void abc ();
void bcd ();
};
Class A is defined in MyLib ie (A.cpp) is in MyLib and it also contains
A.h
Main.cpp also #include "A.h"
Now if change the A.h #included in Main.cpp only as
//A.h changed only in Main.cpp
//A.h
class A {
public:
A();
void abc ();
void bcd ();
Test () {std::cout << "hello world " << std::endl; }
};
This still compiles and I can invoke the Test in Main.cpp. This
compiles even if Test is non-inline.
Does n't this violate the One Definition rule of C++. Also how does the
linker resolve this
gcc B.o Main.o -lMyLib
//A.h
class A {
public:
A();
void abc ();
void bcd ();
};
Class A is defined in MyLib ie (A.cpp) is in MyLib and it also contains
A.h
Main.cpp also #include "A.h"
Now if change the A.h #included in Main.cpp only as
//A.h changed only in Main.cpp
//A.h
class A {
public:
A();
void abc ();
void bcd ();
Test () {std::cout << "hello world " << std::endl; }
};
This still compiles and I can invoke the Test in Main.cpp. This
compiles even if Test is non-inline.
Does n't this violate the One Definition rule of C++. Also how does the
linker resolve this