Hello, I am having trouble with linker error...
This is my first stab at creating inherited objects. I cannot seem to get them working. I get the following errors:
This is my first stab at creating inherited objects. I cannot seem to get them working. I get the following errors:
Code:
busdes.obj : error LNK2001: unresolved external symbol "public: void __thiscall model::openfile(char *,int)" (?openfile@model@@QAEXPADH@Z)
Debug/bus_program.exe : fatal error LNK1120: 1 unresolved externals [\code]
I've created objects: model & UserInput
(edited code)
[code] // "model.h"
#ifndef BP_MODEL_H
#define BP_MODEL_H
#include<fstream.h>
class model{
public:
model();
void openfile(char*, int); // opens file "char*" and ignores "int" lines
};
#endif [\code]
I have a model.cpp file that includes this file with the function:
[code]openfile(char* filename, int lines){cout<<"test\n";"[\code]
The code for the child goes something like this:
[code] // "UserInput.h"
#ifndef BP_USERINPUT_H
#define BP_USERINPUT_H
#include <iostream.h>
#include <iomanip.h>
#include "model.h" // needed because of ifndef...
class UserInput: public model{public: int a=1;};
#endif [\code]
and main goes something like this:
[code]
#include<cstring>
#include<iostream.h>
#include<iomanip>
#include "model.h"
#include "UserInput.h"
int main(){
UserInput ui1;
ui1.openfile("myfile.txt", 0);
return(0);
}
Help would be GREATLY appreciated. I have no idea why this doesn't work.