Background:
I am a newbie to programming.
I just started using this compiler, I used to use visual c++ .NET and I never had any linking problems there.
Problem:
I tried out with a simple program about a buffer and I got thease errors:
Code:
Linker Warning: No module definition file specified: using defaults
Linker Error: Undefined symbol Buffer::~Buffer() in Module Main.cpp
Linker Error: Undefined symbol Buffer::DisplayBuff() in Module Main.cpp
Linker Error: Undefined symbol Buffer::ClearBuff() in Module Main.cpp
Linker Error: Undefined symbol Buffer::Buffer() in Module Main.cpp
Now here is the program:
Main.cpp
Code:
#include "Buffer.h"
int main()
{
Buffer a;
a.ClearBuff();
a.DisplayBuff();
return 0;
}
Buffer.h
Code:
#ifndef BUFFER_H
#define BUFFER_H
//class Buffer
class Buffer {
public:
Buffer();
~Buffer();
void Add(int Pos, char *b);
void ClearBuff();
void DisplayBuff();
private:
char *a;
};
#endif
Buffer.cpp
Code:
#include <iostream.h>
#include <string.h>
#include "Buffer.h"
Buffer::Buffer()
{
a = new char[1999];
}
Buffer::~Buffer()
{
delete[] a;
}
void Buffer::Add(int Pos, char *b)
{
int i = 0;
for (i = 0; i < strlen(b); i++)
{
if (Pos+i > 1999 || Pos+i < 0)
return;
a[Pos+i] = b[i];
}
}
void Buffer::ClearBuff()
{
int i = 0;
for (i = 0; i < 1999; i++)
a[i] == ' ';
}
void Buffer::DisplayBuff()
{
int i = 0;
for (i = 0; i < 1999; i++)
cout << a[i];
}
Sorry for bothering you guys but I really would like to fix this problem. Thanks for any help.