Hi everybody;
During my coding, I have encountered a problem.I appreciate if anybody answer it.
Here is the simplified code:
//Header5.h
#pragma once
#include <string>
using namespace std;
class Parameter {
protected:
int attribute;
public:
virtual Parameter* operator+(Parameter* a)=0;
};
class MyInteger: public Parameter{
public:
//constructors
MyInteger(void);
MyInteger(int incoming);
//functions
MyInteger* operator+(MyInteger* a);
};
class SpecialType: public Parameter{
public:
//Constructors
SpecialType(void);
SpecialType(int incoming);
//Functions
SpecialType* operator+(SpecialType* a);
};
//Source5.cpp
#include "Header5.h"
#include <stdlib.h>
#include <iostream>
#include <string>
#define THE_LAST -1;
using namespace std;
//Constructors of MyInteger
MyInteger::MyInteger(void){
this->attribute = 0;
}
MyInteger::MyInteger(int incoming){
this->attribute = incoming;
}
//function of MyInteger
MyInteger* MyInteger::operator +(MyInteger* a){
MyInteger result; //Here is the bad line.
result.attribute = (this->attribute) + (a->attribute);
return &result;
}
//Constructors of SpecialType
SpecialType::SpecialType(void){
this->attribute = 0;
}
SpecialType::SpecialType(int incoming){
this->attribute = incoming;
}
//function of SpecialType
SpecialType* SpecialType::operator +(SpecialType* a){
//Buralarda hep operator overloading olacak.
SpecialType result;
result.attribute = (this->attribute) - (a->attribute);
return &result;
}
int main(int argc, char**argp){
MyInteger a;
SpecialType b;
return 4;
}
Here are the definition of error:
error C2259: 'MyInteger' : cannot instantiate abstract class
due to following members:
thanks in advance!