Start New Discussion within our Software Development Community

i searched about this error. they said is mostly caused by forgot putting semicolon...
but i find for 1hours+ still cant find out >.< anyone can help me?

the error is pointing test.h lines 9: multiple types in one declaration


test.h:

#ifndef TEST_H_
#define TEST_H_

class TEST
{
	public:
		//call when pixel haven't allocated
		void stPixel ();
};

#endif

test.cpp:

#include <iostream>
#include "Struct.h"
#include "Test.h"
using namespace std;

//struct
extern PIXEL *pixel;


//call when pixel haven't allocated
void TEST :: stPixel ()
{
	int size;
	cout<<"Enter how many struct pixel you need: ";
	cin>>size;
	pixel = new (nothrow) PIXEL [size];
	if(pixel == 0)
	{
		cout<<"Error: pixel memory could not be allocated\n";
	}
	else
	{
		cout<<"Created pixel struct in size of "<<size<<", key in the numbers to the array\n";
		for(int i=0; i<size; i++)
		{
			cin>>pixel[i].x;
		}
		for(int i=0; i<size; i++)
		{
			cout<<pixel[i].x<<" ";
		}
	}	
}

Its possible the issue lies in struct.h an incomplete type or syntax error there could easily have such a knock on effect. Can you post struct.h code too please?

Alternatively if you cannot do that, then swap the order of your includes to include test.h first and see if the error remains constant.

This question has already been answered. Start a new discussion instead.