titanandrews
Programmer
Hi,
I am having some difficulty on the link step when I try to compile a multiple file program. I really don't understand why the linker complains. Could someone take a look at the following files and see if you know why?
Here is my compile command:
cl /GX /GZ /Zi main.cpp Base.cpp Derived.cpp
If I just put everything in a couple of files, then it works okay, but that's not what I want. Any suggestions?
many thanks,
Barry
I am having some difficulty on the link step when I try to compile a multiple file program. I really don't understand why the linker complains. Could someone take a look at the following files and see if you know why?
Code:
//Base.h file
#ifndef __Base_H__
#define __Base_H__
class Base
{
public:
virtual void aFunc();
};
#endif
//Base.cpp file
#include "Base.h"
void aFunc()
{
int i = 0;
}
//Derived.h file
#ifndef __Derived_h__
#define __Derived_h__
#include "Base.h"
class Derived : public Base
{
public:
virtual void aFunc();
};
#endif
//Derived.cpp file
#include "Derived.h"
void aFunc()
{
int y = 0;
}
//main.cpp file
#include "Base.h"
#include "Derived.h"
int main(int argc,char *argv[])
{
Base base;
Derived deriv;
return (1);
}
Here is my compile command:
cl /GX /GZ /Zi main.cpp Base.cpp Derived.cpp
If I just put everything in a couple of files, then it works okay, but that's not what I want. Any suggestions?
many thanks,
Barry