I have a program I am working for the class I am taking. The goal is to create a default,paramertized and copy constructor for a resistor value. I have been unable to get it to pass the compiler due to one error,
" c:\documents and settings\mark\desktop\visual studio\week4\dilday_week 4\dilday_week 4\dilday_week 4.cpp(19) : error C2470: 'Class' : looks like a function definition, but there is no parameter list; skipping apparent body"
This error points to,
"class Resistor Class
{ " ,in the program. If I can get past this I can debug the rest of the code.Here is the full code, take it easy on my code I am new at this.
"// Dilday_Week 4.cpp : Defines the entry point for the console application.
void main() is not standard.
main() is inside a class declaration.
main() is explicitly calling ResisorClass's constructor, which is illegal.
There's a bunch of stuff which should be inside functions but are just lying around the class declaration.
What can I tell you? Reread the entire chapter on classes of your material.
I'll give you an example of what a properly written class looks like as there isn't much else I can do:
#include <iostream>
class A{
int *data;
A(int);
~A();
int getData();
};
A::A(int a){
this->data=newint;
*this->data=a;
}
A::A(int a){
deletethis->data;
}
int A::getData(){
return *this->data;
}
//main() returning anything other than int is non-standard.
int main(){
//A::A(); //<- Illegal
A a;
std::cout <<a.getData<<std::endl;
return 0;
}