Hi all!
I have just started learning c++ and i have a lil' problem compiling one of my programs (ADT).


I havent finished it yet and started partialy verifying it, if it's correct or not, but i just met an error and i have no idea what the hell is wrong because i compiled it on other computers and it gives no errors there. Maybe someone can help.

***header file

typedef struct
{int maxnr;
 int n; 
 int *a; 
}VE;

void init(VE&,int,int);
void readseq(VE&);
void printseq(VE);

***modul

#include "m3.h"
#include "iostream.h"
#include "conio.h"

void init(VE& x,int maxe,int nre)
{x.maxnr=maxe;
 x.n=nre;
 x.a=new int[maxe];
}

void readseq(VE& x)
{int db=0;
int y;
VE q;
cout<<db<<".element: ";
cin>>y;
while (y>=0)
{db++;
 init(q,db,db);
 for (int i=0;i<db;i++)
 {q.a[i]=x.a[i];}
 q.a[db]=y;
 x=q;
 delete [] q.a;
 cout<<db<<".element: ";
 cin>>y;
 }
}

void printseq(VE x)
{for (int i=0;i<x.n;i++)
{cout<<"x["<<i<<"] = "<<x.a[i]<<endl;}
}

***main

#include "m3.h"
#include "iostream.h"
#include "conio.h"

void main()
{ VE z;
  readseq(z);
  printseq(z);
  getch();
  }

Error messages in line 7 and 8 in the header file.

What compiler are you using that produces the error? There is nothing wrong with that header file. You don't need to typedef that struct in C++ because structs are almost identical to classes. So all you need is this:

struct VE
{int maxnr;
 int n; 
 int *a; 
};

I'm using BorlandC, the profs' at the university forces us :P. That's the problem,i can't find any problems there myself, and it really makes me nervous that it runs on other computers, using the same compiler, and it doesn't runs on this ...

try moving m3.h down below the other header files in the *.cpp files. Maybe your compiler just doesn't like it to be the first header file.

that doesnt solves the problem :( any other ideas? i have to make it for tomorrow :|

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.