help c + + code

hello I have to return with struct and registration

follows the code in c + + with error


MENU - (Show on Screen)
1 - Read vector data (record of grades 5)
2 - Display data vector
3 - Mean of vector elements
4 - Exit



#include <iostream>
using namespace std;



struct cadastronotas{



int main ()
{
char n[5];
int op,i;
float media;

struct cadastranotas notas[5];

cout<<" 1 - Ler dados do vetor (cadastro de 5 notas)"<<endl;
cout<<" 2 - Exibir dados do vetor"<<endl;
cout<<" 3 - Media dos elementos do vetor"<<endl;
cout<<" 4 - Sair"<<endl;
cin>>op;
system("cls");

}


do {
if (op==1)
{
for (i=1;i<=5;i++)
{
cout<<"Digite a nota"<<i<<"=";
cin>>cadastranotas[i].notas;
nt++;
media=nt/5;
}

else if (op==2)
{
exibir_dados(notas);
system("cls");
}

else if (op==3)
{
exibir_dados(notas);
system("cls");
}

else if (op==4)
{
exibir_dados(notas);
system("cls");
}

cout<<" 1 - Ler dados do vetor (cadastro de 5 notas)"<<endl;
cout<<" 2 - Exibir dados do vetor"<<endl;
cout<<" 3 - Media dos elementos do vetor"<<endl;
cout<<" 4 - Sair"<<endl;
cin>>op;
system("cls");

}while ((op==1)||(op==2)||(op==4));

}

system("pause");
}


closed account (j3Rz8vqX)
With c++, you cannot encapsulate the main function in an object.

Illegal example:
1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;

struct it{
    int main()
    {
        return 0;
    }
};


Legal example:
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;

struct it{
    //blank for illustration
};

int main()
{
    return 0;
}
Last edited on
return as well?
The main function and return from main are going to be outside of any struct definition.
Topic archived. No new replies allowed.