Jump to content

Hello, first post... Been here a while (not signed in), now need help.

 

I'm having problems with placing classes in separate files. 

 

I'm currently using Code::Blocks and am getting this error message:

 

Undefined reference to "Orange::Orange()"

 

My code:

 

Main.cpp

#include <iostream>#include "Orange.h"using namespace std;int main(){    Orange testObject;    cout << "I like cake" << endl;}

Orange.h

#ifndef ORANGE_H#define ORANGE_Hclass Orange{    public:        Orange();    private:        int Pebble = 10;        int fish = 0;};#endif // ORANGE_H

Orange.cpp

#include <iostream>#include "Orange.h"using namespace std;Orange::Orange():Pebble(10), fish(22){    cout << "Hello World" << endl;    cout << Pebble << endl;    cout << fish << endl;}

I have no clue what is going on.

 

Pretty lengthy first post, and pretty formal. That's odd.

 

Thanks in advance. And please do tell me if I am making a newb mistake, as I am a complete newb.

Link to comment
https://linustechtips.com/topic/197045-c-help/
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

×