idk why i get this error i just do

here is the code i have:

#include "includes.h"

int main()
{

}

here is the error:
c:\documents and settings\tom\my documents\visual studio 2008\projects\c++ tutorial\c++ tutorial\main.cpp(3) : error C2143: syntax error : missing ';' before 'int'

any ideas?

At the first place i dont know wat r u trying to do here .

Well i guess if you include the main header file also i.e
#include<iostream.h>
u may not get this error.

thats included in std_lib_facilities.h, its for a tutorial im doing. mabey the VC++ compiler is just screwing up

yeah .. that sounds k . but did you try this way i mentioned . before ?

still does the same thins :S

main needs paramaters and needs to return a value, else its not valid standard c++

i tried that and it still doesnt work :(

well when i ran this program

#include<iostream.h>
int main()
{
}

it didnt give me ne errors .
well i work on codeblocks IDE and GCC compiler i guess

Maybe you could post the "includes.h" file?

main.cpp:

#include "std_lib_facilities.h"
#include "maindef.h"
#include "date.h"

int main(int argc, char* argv[])
{
	cout<<"Hello!, "<<argv[0]<<'\n';
	keep_window_open(); //the equivilent of cin.get();
	return 0;
}

maindef.h:

#ifndef _maindef_h_
#define _maindef_h_

#include "std_lib_facilities.h"

#define BOOL int
#define NULL 0
#define FALSE NULL
#define TRUE 1

template<typename t> class list {
	int sz;
	t elem;
public:
	list() : sz(0), elem(new t[0]){ }
	list(int i) : sz(i), elem(new t[i]){ }
	list(int i, int val) : sz(i), elem(new t[i])
	{
		for(int i=0;i>sz;i++) cout<<elem[i];
	}

	list operator[](int i){ return elem[i]; }

	void printAll(void);
}

#endif /* _maindef_h_ */

date.h:

#ifndef _date_h_
#define _date_h_

#include "maindef.h"
#include "std_lib_facilities.h"

class Date {
	//private data members
	int y, m, d;

	//for error checking
	class invalid{ };
public:
	//constructor
	Date(int y, int m, int d);
	BOOL check(void);
	
	//modifying functions
	void add(char ch, int i);

	//access functions
	int year(){ return y; }
	int month(){ return m; }
	int day(){ return d; }
};

#endif /* _date_h_ */

date.cpp:

#include "date.h"
#include "std_lib_facilities.h"
#include "maindef.h"

Date::Date(int y, int m, int d)
:y(y), m(m), d(d)
{
	if(!check()) throw invalid();
}

void Date::add(char ch, int i)
{
	int val = 0;

	if(ch == 'y')
		val = 1;
	else if(ch == 'm')
		val = 2;
	else if(ch =='d')
		val = 3;
	else
		error("invalid param called to Date::add()");

	switch(i)
	{
	case 1:
		y += i;
	case 2:
		m += i;
	case 3:
		d += i;
	}
}

BOOL Date::check(void)
{
	if((d<0 || 31>d) && (m<1 || 12>m) && (y<0 || 2009>12)	)
		return FALSE;
	else
		return TRUE;
}

maindef.cpp:

#include "maindef.h"
#include "std_lib_facilities.h"

list::list(int i, int val)
: sz(i), elem(new t[i])
{
	for(int i=0;i>sz;i++)
		elem[i] = val;
}

void list::printAll(void)
{
	for(int i=0;i>sz;i++)
	{
		cout<<elem[i];
	}
}

std_lib_facilities(not writen by me):

/*
	simple "Programming: Principles and Practice using C++" course header to
	be used for the first few weeks.
	It provides the most common standard headers (in the global namespace)
	and minimal exception/error support.

	Students: please don't try to understand the details of headers just yet.
	All will be explained. This header is primarily used so that you don't have
	to understand every concept all at once.
*/

#ifndef H112
#define H112 200608L

#include<iostream>
#include<fstream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<stdexcept>
using namespace std;


template<class T> string to_string(const T& t)
{
	ostringstream os;
	os << t;
	return os.str();
}

struct Range_error : out_of_range {	// enhanced vector range error reporting
	int index;
	Range_error(int i) :out_of_range("Range error: "+to_string(i)), index(i) { }
};


// trivially range-checked vector (no iterator checking):
template< class T> struct Vector : public std::vector<T> {
	typedef typename std::vector<T>::size_type size_type;
	Vector() { }
	explicit Vector(size_type n) :std::vector<T>(n) {}
	Vector(size_type n, const T& v) :std::vector<T>(n,v) {}

	T& operator[](unsigned int i) // rather than return at(i);
	{
		if (i<0||this->size()<=i) throw Range_error(i);
		return std::vector<T>::operator[](i);
	}
	const T& operator[](unsigned int i) const
	{
		if (i<0||this->size()<=i) throw Range_error(i);
		return std::vector<T>::operator[](i);
	}
};

// disgusting macro hack to get a range checked vector:
#define vector Vector

// trivially range-checked string (no iterator checking):
struct String : std::string {
	
	String() { }
	String(const char* p) :std::string(p) {}
	String(const string& s) :std::string(s) {}
	String(int sz, char val) :std::string(sz,val) {}
	template<class Iter> String(Iter p1, Iter p2) : std::string(p1,p2) { }

	char& operator[](unsigned int i) // rather than return at(i);
	{
		if (i<0||size()<=i) throw Range_error(i);
		return std::string::operator[](i);
	}

	const char& operator[](unsigned int i) const
	{
		if (i<0||size()<=i) throw Range_error(i);
		return std::string::operator[](i);
	}
};



struct Exit : runtime_error {
	Exit(): runtime_error("Exit") {}
};

// error() simply disguises throws:
inline void error(const string& s)
{
	throw runtime_error(s);
}

inline void error(const string& s, const string& s2)
{
	error(s+s2);
}

inline void error(const string& s, int i)
{
	ostringstream os;
	os << s <<": " << i;
	error(os.str());
}

#if _MSC_VER<1500
	// disgusting macro hack to get a range checked string:
	#define string String
	// MS C++ 9.0 have a built-in assert for string range check
	// and uses "std::string" in several places so that macro substitution fails
#endif

template<class T> char* as_bytes(T& i)	// needed for binary I/O
{
	void* addr = &i;	// get the address of the first byte
						// of memory used to store the object
	return static_cast<char*>(addr); // treat that memory as bytes
}


inline void keep_window_open()
{
	cin.clear();
	cout << "Press enter to continue...";
	cin.get();
	return;
}

inline void keep_window_open(string s)
{
	if (s=="") return;
	cin.clear();
	cin.ignore(120,'\n');
	for (;;) {
		cout << "Please enter \"" << s << "\" to exit\n";
		string ss;
		while (cin >> ss && ss!=s)
			cout << "Please type \"" << s << "\" to exit\n";
		return;
	}
}

// make std::min() and std::max() accessible:
#undef min
#undef max

#include<iomanip>
inline ios_base& general(ios_base& b)	// to augment fixed and scientific
{
	b.setf(ios_base::fmtflags(0),ios_base::floatfield);
	return b;
}

// run-time checked narrowing cast (type conversion):
template<class R, class A> R narrow_cast(const A& a)
{
	R r = a;
	if (A(r)!=a) error(string("info loss"));
	return r;
}


inline int randint(int max) { return rand()%max; }

inline int randint(int min, int max) { return randint(max-min)+min; }

#endif

as i said before, this code is all for a book i bought called "Programming principals and prictice using c++" by Bjarne Stroustrup(the original designer and implementer of c++)
this code has worked before(as far as i can remember)

all your help has and will be apprecieted :)

Your missing a semicolon ( ; ) at the end of your class in maindef.h. So add one after the last } ( so: }; )

A semi-colon wouldn't go amiss at the end of this definition in maindef.h :

template<typename t> class list {...};

thanks man that fixed it. :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.