Jump to content

C++ object oriented programming error

OverclockingNub
Go to solution Solved by C2dan88,

You probably need to configure coderunner to compile all .cpp files for the open project not just the active cpp file you have open in the editor

 

Stackoverflow discusses the problem

https://stackoverflow.com/questions/57502306/running-c-with-vstudio-code-using-coderunner-extension

i have three seperate files, one is testcode.cpp, another is Cat.h and lastly Cat.cpp

im trying to create an object of class Cat and make it meow but im getting an error that i dont know how to fix. any ideas?

<

#include <iostream>
#include "Cat.h"
using namespace std;


 
int main(){
Cat kitty;
kitty.speak();
return 0;
}

>

from testcode.cpp

 

<

#ifndef CAT_H_
#define CAT_H_
 
class Cat {
public:
void speak();
};
 
#endif /* CAT_H_ */

>

 

from Cat.h

 

<

 
#include <iostream>
#include "Cat.h"
using namespace std;
 
void Cat::speak(){
cout<< "meow" << endl;
}
int main(){
}

>

from Cat.cpp

 

the error is attached

Screen Shot 2024-01-01 at 12.15.51 PM.png

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×