Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After public it says expected expression. why and how do I fix it?
#include <qtglobal>
#include "soundevent.h"

SoundEvent::SoundEvent()
{
public: <<<<<<<<<<<<<<<<<<<
SoundEvent(qint64 timestamp = 0, int soundId = 0);
~SoundEvent();
qint64 timestamp;
int soundId;
}

What I have tried:

After public it says expected expression. why and how do I fix it?
#include <qtglobal>
#include "soundevent.h"

SoundEvent::SoundEvent()
{
public: <<<<<<<<<<<<<<<<<<<
SoundEvent(qint64 timestamp = 0, int soundId = 0);
~SoundEvent();
qint64 timestamp;
int soundId;
}
Posted
Updated 24-Dec-20 15:48pm

1 solution

The problem is this :
C++
SoundEvent::SoundEvent()
That is the implementation of the class' constructor. That appears to be the declaration of the class which should appear like this :
C++
class SoundEvent
{
public:
    SoundEvent( qint64 timestamp = 0, int soundId = 0 );
    ~SoundEvent();

    qint64 timestamp;
    int soundId;
};
The implementation of the constructor should appear like this :
C++
SoundEvent::SoundEvent( qint64 timestamp, int soundId )
{
    // code goes here
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900