I used to use visual studio as a compiler for C++. I have been recently using g++ in cygwin. My problem is I donot know how to use cygwin for inheritance. The code below is just for illustration, to make my question more clearer.
Base class:
// A.h:
class A{
void func1();
};
class B:A{
func2();
};
//-------------
//A.cpp:
#include"A.h";
A::func1(){
};
//-----------
//B.cpp:
#include"A.h";
B::func2(){
func1();
};
int main(){
B b.
b.func2();
return 0;}
//----------------
I run (similar to ) this without any problem in visual studio. But I do not know how to run it in cygwin. How to include A.h , A.cpp, to run main() in B.cpp.
You need to compile your class implementation files into object files first, then link them.
If you were to use the g++ compiler, you could run these commands...
g++ -c A.cpp
g++ -c B.cpp
g++ A.o B.o main.cpp -o my_program
This can be automated with a Makefile, so you don't have to type everything out. As others have mentioned GDB can also be used for debugging, but you need to add the '-g' option to your compiler flags to created debugging symbols.
Also, you have a period at the end of line 1 of your main function, rather than a semi-colon.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments