ctor not allowed return type
May 10, 2014 at 9:50am UTC
Hello.
I wrote a part of code I need for my projects in algorithms class, and i get this message
error C2533: 'Entropy::{ctor}' : constructors not allowed a return type
I don't understand why it keeps returning this message, because I didn't specified any return type for constructor. (If I did, please let me know)
If someone could help me, I'd be very grateful.
cetnost.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#pragma once
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
class Entropy
{
private :
int count;
char slovo;
double entropie;
double sum;
protected :
public :
Entropy(char x);
virtual ~Entropy();
void AddCount();
int GetCount();
void DoEntropy();
void DoSum();
double GetEntropy();
double GetSum();
char GetSlovo();
}
cetnost.cpp
1 2 3 4 5 6 7
#include "cetnost.h"
Entropy::Entropy(char x)
{
count = 1;
slovo = x;
} //cstr
Last edited on May 10, 2014 at 9:51am UTC
May 10, 2014 at 10:00am UTC
1 2 3 4
class Entropy
{
// ...
} ; // *** need a semicolon here ***
And ideally, make the code const-correct
1 2
int GetCount() const ; // does not modify the object
// etc.
May 10, 2014 at 10:02am UTC
Yeah, thanks, my bad.
Topic archived. No new replies allowed.