P
Peskov Dmitry
It is a very basic question.Surely i got something wrong in my basic
understanding.
//Contents of file1.cpp
using namespace std;
#include <iostream>
template <typename T>
class my_stack;
int main(){
my_stack<int> st1;
int top_element;
top_element = st1.pop();
cout << "Hello World !! Top = " << top_element << endl;
return 0;
}
The class my_stack is defined in another file. say (template.cpp)
file.o template.o -> project
why does it give linker error, since i provided the class definition
while linking too !!!
../src/file1.cpp: In function ‘int main()’:
../src/file1.cpp:8: error: ‘my_stack’ was not declared in this scope
understanding.
//Contents of file1.cpp
using namespace std;
#include <iostream>
template <typename T>
class my_stack;
int main(){
my_stack<int> st1;
int top_element;
top_element = st1.pop();
cout << "Hello World !! Top = " << top_element << endl;
return 0;
}
The class my_stack is defined in another file. say (template.cpp)
file.o template.o -> project
why does it give linker error, since i provided the class definition
while linking too !!!
../src/file1.cpp: In function ‘int main()’:
../src/file1.cpp:8: error: ‘my_stack’ was not declared in this scope