Hello there!
Thanks for visiting my topic, to get it straigt, I am seeking for help. Before you ask me: Nope, im not coding since yesterday, yes i googled my problem, yes i asked my mentor for help (he had no clue either) so don't think i want to waste your time or abuse this forum :)
First off I'll show you the problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#pragma once
#ifndef VERGLEICHER_H
#define VERGLEICHER_H
#include "punkt.h"
using namespace std;
class Vergleicher{
public:
virtual bool kleiner(const Punkt& p1, const Punkt& p2) = 0;
};
#endif /* VERGLEICHER_H */
|
this class was intented to inherit the function kleiner ( this means smaller) to 3 other classes but unfortunatley I get this error:
"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
Here are some things I already tried to fix this problem:
-remove #pragma from code
-remove function arguments (this was a bad idea)
-remove all commands to the compiler
-write the class in the same .h than the other 3 classes
-delete and rewrite the class
-adding/removing namespace std (no effect at all)
-switching (const Punkt& p1 ....) to (Punkt p1, ...)
-trying to use a virtual int instead of a virtual bool (got same error)
-trying to use no virtual class at all (still same error?!?!?!?!)
-writing the code on a friends laptop with another version of Visual Studio
-google it
-google it again
-annoy my friends to help me
-annoy my mentor to help me
-google it again
########################################################
############ SOLUTION ##################################
########################################################
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#pragma once
#ifndef VERGLEICHER_H
#define VERGLEICHER_H
struct Punkt { //I declared this struct here instead
int x, y; //of using compiler orders
};
class Vergleicher{
public:
virtual bool kleiner(Punkt& p1,Punkt& p2) = 0; // <- they are not const any longer!
};
#endif /* VERGLEICHER_H */
|
Now if u think its a problem that point p1 and p2 are not const anylonger, dont be worried! When inheriting the abstract class (Yep thats the WHOLE class) u can add "const" again and he wont overwrite/reinterpret the method!
Thanks for everyone who helped me to figure this finally out:
Branflakes91093
TheIdeasMan
Disch
Have a great weekend gentlemen :)