VC++ 6.0 constructors not allowed a return type?!??!

Hey All,
Please help if you can, I'm sure it's something simple (isn't it always!! :) ) but it has me baffled.
I am writing some C++ classes, Multiplexor has a subclass called AllStreamsMuxer See the following code:

-----------------------------------MULTIPLEXOR.H---------------------------------------

#ifndef _Multiplexor_H_
#define _Multiplexor_H_

class Multiplexor
{
      public:
            struct UnmuxedPacket
            {
                  Float64 cts;
                  int payload_length;
                  char header_data[RTP_HEADER_SIZE];
                  char payload_data[MAX_MTU_SIZE];
            };

            Multiplexor();
            ~Multiplexor();
            virtual Float64 getPacket(char ** outPacket, int * outPacketLength);

      protected:
            char multiplexed_packet[MAX_MTU_SIZE];

            virtual UInt32 getFullBufferEsId();                  
};

#endif // _Multiplexor_H_

----------------------------------MULTIPLEXOR.CPP----------------------------------------

#include "Multiplexor.h"

Multiplexor::Multiplexor()
{
      
}

Multiplexor::~Multiplexor()
{
      
}

------------------------------ALLSTREAMSMUXER.H------------------------------------------

#ifndef _AllStreamsMuxer_H_
#define _AllStreamsMuxer_H_

#include "Multiplexor.h"

class AllStreamsMuxer : public Multiplexor
{
      public:
            AllStreamsMuxer();
            ~AllStreamsMuxer();

      private:
            UnmuxedPacket multiplex_buffer[MAX_PACKETS_PER_MUX_PACKET];
            UInt32 current_buffer_location;
};

#endif // _AllStreamsMuxer_H_

------------------------------------ALLSTREAMSMUXER.CPP-----------------------------------------------------

#include "AllStreamsMuxer.h"

AllStreamsMuxer::AllStreamsMuxer()
{
      current_buffer_location = 0;
}

AllStreamsMuxer::~AllStreamsMuxer()
{
      
}

Float64 Multiplexor::getPacket(char ** outPacket, int * outPacketLength)
{
      return 5.5;
}

UInt32 Multiplexor::getFullBufferEsId()
{
      return 1;
}

-----------------------------------------------------------------------------------------------------------------
The problem is that it won't compile and it gives the error:
"AllStreamsMuxer.cpp(4) : error C2533: 'AllStreamsMuxer::AllStreamsMuxer' : constructors not allowed a return type"

I can't see how it is picking up a returned typed ( I suspect that another error has confused the compiler and causing an incorrect diagnosis).  I have looked at http://lists.wxwidgets.org/archive/wx-users/msg21063.html but I can't see any relation, I appear to have the semicolon in the right place as far as I can see.
I would be grateful for your suggestions / solutions.
Stef
LVL 1
stefargAsked:
Who is Participating?
 
jkrCommented:
Well, that might explain the difference - once the precompiled header file is deleted, a re-parse is enforced...
0
 
jkrCommented:
Hum. Regarding the code you posted, there don't seem to be any obvious problems...
0
 
stefargAuthor Commented:
Yeah, that's what I thought, but I just thought that someone who hasn't been bogged down in the code may be able to spot the problem (hopefully!)
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
jkrCommented:
Any problems with the other header files? I mean, a few of the data types you are using are not declared in the above code...
0
 
idtCommented:
I added

#define RTP_HEADER_SIZE 1
#define MAX_MTU_SIZE 1
#define MAX_PACKETS_PER_MUX_PACKET 1
typedef double Float64;
typedef unsigned long UInt32;

to Multiplexor.h

and both cpp files compiled to object code just fine except:
note that class Multiplexor has virtual functions yet the destructor is non-virtual
and the same for class AllStreamsMuxer

So.. to compile totally clean

in Multiplexor.cpp
//Multiplexor::~Multiplexor()
//{
//
//}

in Allstreamsmuxer.cpp
//AllStreamsMuxer::~AllStreamsMuxer()
//{
//
//}

in Allstreamsmuxer.h
//~AllStreamsMuxer();
virtual ~AllStreamsMuxer();

in Multiplexor.h
//~Multiplexor();
virtual ~Multiplexor();

Daniel
0
 
jkrCommented:
>>So.. to compile totally clean

Did that yield any errors?
0
 
jkrCommented:
Ooops, forget about my last post...

I just compiled the following as a single .cpp file without any problems:

#define RTP_HEADER_SIZE 1
#define MAX_MTU_SIZE 1
#define MAX_PACKETS_PER_MUX_PACKET 1
typedef double Float64;
typedef unsigned long UInt32;

//-----------------------------------MULTIPLEXOR.H---------------------------------------

#ifndef _Multiplexor_H_
#define _Multiplexor_H_

class Multiplexor
{
    public:
         struct UnmuxedPacket
         {
              Float64 cts;
              int payload_length;
              char header_data[RTP_HEADER_SIZE];
              char payload_data[MAX_MTU_SIZE];
         };

         Multiplexor();
         ~Multiplexor();
         virtual Float64 getPacket(char ** outPacket, int * outPacketLength);

    protected:
         char multiplexed_packet[MAX_MTU_SIZE];

         virtual UInt32 getFullBufferEsId();              
};

#endif // _Multiplexor_H_

//----------------------------------MULTIPLEXOR.CPP----------------------------------------

//#include "Multiplexor.h"

Multiplexor::Multiplexor()
{
   
}

Multiplexor::~Multiplexor()
{
   
}

//------------------------------ALLSTREAMSMUXER.H------------------------------------------

#ifndef _AllStreamsMuxer_H_
#define _AllStreamsMuxer_H_

//#include "Multiplexor.h"

class AllStreamsMuxer : public Multiplexor
{
    public:
         AllStreamsMuxer();
         ~AllStreamsMuxer();

    private:
         UnmuxedPacket multiplex_buffer[MAX_PACKETS_PER_MUX_PACKET];
         UInt32 current_buffer_location;
};

#endif // _AllStreamsMuxer_H_

//-----------------ALLSTREAMSMUXER.CPP-----------------------------------------------------

//#include "AllStreamsMuxer.h"

AllStreamsMuxer::AllStreamsMuxer()
{
    current_buffer_location = 0;
}

AllStreamsMuxer::~AllStreamsMuxer()
{
   
}

Float64 Multiplexor::getPacket(char ** outPacket, int * outPacketLength)
{
    return 5.5;
}

UInt32 Multiplexor::getFullBufferEsId()
{
    return 1;
}
0
 
idtCommented:
No compiled clean with -Wall, note that I compiled using gcc 3.2 on a Linux 2.4.20
Just compiled with Intel Compiler for Linux ICC v7 also compiled except it noted that parameter "outPacket" was never referenced
Float64 Multiplexor::getPacket(char ** outPacket, int * outPacketLength)

Daniel
0
 
jkrCommented:
I gave it a try with VC6SP5 here :o)
0
 
idtCommented:
What do you think jkr, is this some kind of Microsoftism?
I don't do really any Windows environ programming, mostly Linux,SUN, BSD,  some maintenance of Delphi code, but the last MS compiler I used was C700 (circa 1992?).

Stefarg,  what are your includes? SP level?

Daniel
0
 
jkrCommented:
>>What do you think jkr, is this some kind of Microsoftism?

No, just trying to make clear that the above compiles fine in the same environment and that the error is either in the Compiler  (which would make it a Microsoftism) or in the code that was not shown so far (which I assume :o)
0
 
stefan73Commented:
Hi stefarg,
> constructors not allowed a return type?

If this is what's baffling you - constructors have an implicit return type. It's the class they belong to. Constructors implicitly return "this".

Cheers,
Stefan
0
 
MafaldaCommented:
Seems like a compiler bug.
Your class AllStreamsMuxer is a derived class from class Multiplexor, did you have problems with derived classes in the past ?
Try compiling a simpler case of a derived class and see if you get the same error.
0
 
stefargAuthor Commented:
Thanks for the comments everyone, I'll respond in ascending order. (see subsequent comments)
I'm only back at my computer this morning so that's why I haven't been replying to the messages posted to date.
0
 
stefargAuthor Commented:
Mafalda,
I have only started to implement the subclasses now, AllStreamsMuxer is the first subclass I have written and the Multiplexor superclass worked no problem.

Stefan,
thanks for that but I understand OOP concepts very well, maybe the title I gave was a bit misleading.

idt and jkr,
I think we might have found a serious case of Microsoftism!! Guess what happened this morning when I compiled the project? IT WORKED!! I am very confused as I did not alter the code in any way, it was exactly as above.  I did a clean before I built it so maybe it's possible that a prebuilt file was causing problems?? (Although I did this repeatedly last night...?????)
Anyway, I have made a few changes to the code since so I'll post up what I have so far so that everyone can see it.
(The Multiplexor files have not changed)

----------------------------------AllStreamsMuxer.h-----------------------------------------------
#ifndef _AllStreamsMuxer_H_
#define _AllStreamsMuxer_H_

#include "Multiplexor.h"

class AllStreamsMuxer : public Multiplexor
{
    public:
         AllStreamsMuxer();
         ~AllStreamsMuxer();
             virtual bool insert(QTRTPFile::RTPTrackListEntry* entry);
            virtual Float64 getPacket(char ** outPacket, int * outPacketLength);

      protected:
            virtual UInt32 getFullBufferEsId();

    private:
         UnmuxedPacket multiplex_buffer[MAX_PACKETS_PER_MUX_PACKET];
         UInt32 current_buffer_location;
};

#endif // _AllStreamsMuxer_H_

-------------------------------------AllStreamsMuxer.cpp------------------------------------

#include "AllStreamsMuxer.h"

AllStreamsMuxer::AllStreamsMuxer() : Multiplexor()
{
    current_buffer_location = 0;
}

AllStreamsMuxer::~AllStreamsMuxer()
{
   
}

bool AllStreamsMuxer::insert(QTRTPFile::RTPTrackListEntry* entry)
{
      return false;
}

Float64 AllStreamsMuxer::getPacket(char ** outPacket, int * outPacketLength)
{
    return 5.5;
}

UInt32 AllStreamsMuxer::getFullBufferEsId()
{
    return 1;
}


0
 
stefargAuthor Commented:
Could it be possible that (in true windows style) closing VC++ and restarting the computer could have eliminated the problem, it's the only thing that I can see that is different from last night?
0
 
jkrCommented:
>>it's the only thing that I can see that is different from last night?

Did you do a 'make clean', or in VC++ terms a "Rebuild All" (i.e. deleting intermediate and precompiled header files)?
0
 
stefargAuthor Commented:
Hey jkr,
I went to "batch build..." and selected "clean" and then "build" which I guess is the same as "rebuild all"
Stef
0
 
idtCommented:
Ahh.. well.. now that it's bitten you, you don't have to make that mistake again :)
Nothing like a make clean.

Daniel
0
 
stefargAuthor Commented:
jkr,
Thought it might be something like that, but I did try the same "clean" proceedure last night to no avail.

All,
Well, I think I wrap this up, I think that jkr probably came closest to expalining the problem but I guess we won't find out what exactly what happened because I can't get back to the situation that was causing the error.
Crazy eh, first of all I can't get away from the error, now I can't get back to it to find the cause!!
I think the fairest thing in this situation is to split the results.  Thanks so much for everyone for you help!
Stef
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.