Undefined refernce

0 Frankline M · September 23, 2014
whenever i a create a class and call using the object in main() it shows an error that "undefined reference to a class". But code build the exe but stops it from executing i.e displaying the o/p.

Post a Reply

Replies

Oldest  Newest  Rating
0 Frankline M · September 25, 2014
When I compile my teddy.cpp program, my compiler shows the error "undefined reference to WinMain@16".

 main.cpp:

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

int main()
{
    Blacklist bl(102,1146,6.17);
    Fisher sf("sadiq",bl);
    sf.execute();
    cin.get();
}

blacklist.h:


#ifndef BLACKLIST_H
#define BLACKLIST_H


class Blacklist
{
    public:
        Blacklist(int t, int c, float h);
        void bklist();
    private:
        int target;
        int code;
        float height;
};

#endif // BLACKLIST_H

blacklist.cpp:


#include "Blacklist.h"
#include <iostream>

using namespace std;


Blacklist::Blacklist(int t, int c, float h)
{
    target=t;
    code=c;
    height=h;
}

void Blacklist::bklist(){
    cout << target << "-" << code << "-" << height << endl;
}

fisher.h:

#ifndef FISHER_H
#define FISHER_H
#include "Blacklist.h"
#include <string>
using namespace std;


class Fisher
{
    public:
        Fisher(string n, Blacklist bo);
        void execute();

    private:
        string name;
        Blacklist blcounters;
};

#endif // FISHER_H

fisher.cpp:

#include "Fisher.h"
#include "Blacklist.h"
#include <iostream>

using namespace std;
Fisher::Fisher(string n, Blacklist bo)
:name(n), blcounters(bo)
{
}

void Fisher::execute(){
    cout << name << "-";
    blcounters.bklist();
    cout << "-" << "Sam its time to execute";
}
0 Frankline M · September 26, 2014
thanks buddy....:)
  • 1

C++

107,344 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator