Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm generating this c++ code(header file) from enterprise architect(class diagram) and facing several errors like
1. error C2146: syntax error : missing ';' before '*' on line 24 (Commented)
2. error C2143: syntax error : missing ',' before '&' on line 27 (I commented it out.)

I couldn't find what's wrong with this..
I'm new to C++..




C++
#include "oss.h"
#include "asn1.h"

#if !defined(EA_A82413CF_73C9_4cd6_8B8B_1DB261A17DF0__INCLUDED_)
#define EA_A82413CF_73C9_4cd6_8B8B_1DB261A17DF0__INCLUDED_

class __seqof1 : public OssList
{

public:
	typedef CareerEntry component;

	__seqof1();
	__seqof1(const __seqof1& prm1);
	~__seqof1();
	component * at(OssIndex prm1);  // line 24
	const component * at(OssIndex prm1) const;
	__seqof1 * extract_after(OssIndex prm1, OssIndex prm2);
	OssIndex insert_after(OssIndex prm1, const component& prm2); //line 27
	OssIndex insert_after(OssIndex prm1, __seqof1* prm2);
	int operator !=(const __seqof1& prm1) const;
	__seqof1 & operator =(const __seqof1& prm1);
	int operator ==(const __seqof1& prm1) const;
	OssIndex prepend(const component& prm1);
	OssIndex prepend(__seqof1* prm1);
	int remove_after(OssIndex prm1);
	int remove_front();

};

class BBCard
{

public:
	typedef OssString name;

	typedef OSS_UINT32 age;

	typedef OssString position;

	typedef __seqof1 career;


	virtual ~BBCard();

	BBCard();
	BBCard(const BBCard& prm1);
	BBCard(const name& prm1, BBCard::age prm2, const position& prm3, const career& prm4);
	age & get_age();
	BBCard::age get_age() const;
	career & get_career();
	const career & get_career() const;
	name & get_name();
	const name & get_name() const;
	position & get_position();
	const position & get_position() const;
	int operator !=(const BBCard& prm1) const;
	BBCard & operator =(const BBCard& prm1);
	int operator ==(const BBCard& prm1) const;
	void operator delete(void* ptr);
	void * operator new(size_t size);
	void set_age(BBCard::age prm1);
	void set_career(const career& prm1);
	void set_name(const name& prm1);
	void set_position(const position& prm1);

private:
	BBCard::age age_field;
	BBCard::career career_field;
	BBCard::name name_field;
	BBCard::position position_field;

};

/**
* Specific PDU classes
*/
class BBCard_PDU : public ConcretePDU
{

public:
	virtual ~BBCard_PDU();

	BBCard_PDU();
	const BBCard * get_const_data() const;
	BBCard * get_data() const;
	void set_const_data(const BBCard& d);
	void set_data(BBCard& prm1);

protected:
	OssTypeIndex get_index() const;

};

/**
* Control object class
*/
class bcas_Control : public OssControl
{

public:
	virtual ~bcas_Control();

	bcas_Control();
	bcas_Control(const bcas_Control& prm1);

};

/**
* Universal PDU class
*/
class bcas_PDU : public UniversalPDU
{

public:
	virtual ~bcas_PDU();

	bcas_PDU();
	BBCard * get_BBCard() const;
	const BBCard * get_const_BBCard() const;
	void set_BBCard(BBCard& prm1);
	void set_const_BBCard(const BBCard& prm1);

};

/**
* Representation types
*/
class CareerEntry
{

public:
	typedef OSS_UINT32 from;

	typedef OSS_UINT32 to;

	typedef OssString team;


	virtual ~CareerEntry();

	CareerEntry();
	CareerEntry(const CareerEntry& prm1);
	CareerEntry(CareerEntry::from prm1, CareerEntry::to prm2, const team& prm3);
	CareerEntry(CareerEntry::from prm1, const team& prm2);
	from & get_from();
	CareerEntry::from get_from() const;
	team & get_team();
	const team & get_team() const;
	to * get_to();
	const to * get_to() const;
	void omit_to();
	int operator !=(const CareerEntry& prm1) const;
	CareerEntry & operator =(const CareerEntry& prm1);
	int operator ==(const CareerEntry& prm1) const;
	void operator delete(void* ptr);
	void * operator new(size_t size);
	void set_from(CareerEntry::from prm1);
	void set_team(const team& prm1);
	void set_to(CareerEntry::to prm1);
	int to_is_present() const;

private:
	OSS_UINT32 bit_mask;
	CareerEntry::from from_field;
	CareerEntry::team team_field;
	CareerEntry::to to_field;

};
#endif // !defined(EA_A82413CF_73C9_4cd6_8B8B_1DB261A17DF0__INCLUDED_)
Posted

That is because your CareerEntry class is unknown when used first.

You should use a forward declaration instead of a typedef:
C++
// Forward declaration
class CareerEntry;

class __seqof1 : public OssList
{
public:
// Remove this
//	typedef CareerEntry component;
 
	__seqof1();
	__seqof1(const __seqof1& prm1);
	~__seqof1();
	CareerEntry * at(OssIndex prm1);
	const CareerEntry * at(OssIndex prm1) const;
	__seqof1 * extract_after(OssIndex prm1, OssIndex prm2);
	OssIndex insert_after(OssIndex prm1, const CareerEntry& prm2);
// ...
};

class CareerEntry
{
// ...
};

Using typedefs here is bad style and obfuscates the code.
 
Share this answer
 
Comments
Member 12307076 4-Feb-16 8:18am    
thanks @Jochen..
I put Careerentry class to appropriate location and it resolved the error.
Jochen Arndt 4-Feb-16 8:22am    
Thank you for your feedback and accepting the solution.

Moving the CareerEntry class definition to top is another solution here. The forward declaration is only really necessary when that class in turn would use the __seqof1 class.
Without seeing the included files, it is hard to guess. However, you cannot use CareerEntry class before, at least, a forward declaration.
I mean, the following program is incorrect:
C++
#include <iostream>
using namespace std;

class Foo
{
  typedef Bar B;

  B * b();
};

class Bar
{

};

Bar * Foo::b(){return new Bar();}

int main(){}


because of a missing forward declaration. The following one is fixed:
C++
#include <iostream>
using namespace std;

class Bar; // class forward declaration

class Foo
{
  typedef Bar B;

  B * b();
};

class Bar
{

};

Bar * Foo::b(){return new Bar();}

int main(){}
 
Share this answer
 
Comments
Member 12307076 4-Feb-16 8:47am    
Thanks @Cpallini

got the idea.
one more thing what should I do if my code length is around 18k. how to resolve this kind of errors?

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