I have an array of structs, example: struct mystruct { int blah; double blahblah; };
mystruct mylist[10];
void myfunction(mystruct mylist[]); { //function }
it gives me an error at the '{' after void. what is wrong with my code? sorry for not giving a good example.
Remove that semicolon at the end of:
void myfunction(mystruct mylist[]);
Derek
Let me take a look at my book when I get to work, but I thought the notation for using an array as a function argument was something like
void myfunction(mystruct mylist[], int n)
where n is the number of elements in the array. But it is early in the morning and I am pretty dim to start with.
The earlier note on teh semicolon is also correct, you have done the classic error of creating an empty function, i.e.
void myfunction(mystruct mylist[]); ^ This is your function, the nothing between ) and ;
Common mistake. Done it a lot, will do it some more.
Wayne
Hello, I have this simple program to offer. Hope it can help.
#include <cstdlib> #include <iomanip> //..setprecision ect #include <iostream>
using namespace std;
struct alphaDom { double st_cap; double st_han; double st_kop;
double networkNumber(); };
int main() { cout.setf(ios::fixed); alphaDom NalphaDom = { 103.498, 206.998, 302.986 }; alphaDom* palphaDom = &NalphaDom; cout << endl << "networkNumber is " << setprecision(3) <<palphaDom->networkNumber() << endl << endl;
system("PAUSE"); return 0; }
double alphaDom::networkNumber() { return st_cap * st_han * st_kop; }
Log in to post a comment.
I have an array of structs, example:
struct mystruct
{
int blah;
double blahblah;
};
mystruct mylist[10];
void myfunction(mystruct mylist[]);
{
//function
}
it gives me an error at the '{' after void. what is wrong with my code? sorry for not giving a good example.
Remove that semicolon at the end of:
void myfunction(mystruct mylist[]);
Derek
Let me take a look at my book when I get to work, but I thought the notation for using an array as a function argument was something like
void myfunction(mystruct mylist[], int n)
where n is the number of elements in the array. But it is early in the morning and I am pretty dim to start with.
The earlier note on teh semicolon is also correct, you have done the classic error of creating an empty function, i.e.
void myfunction(mystruct mylist[]);
^
This is your function, the nothing between ) and ;
Common mistake. Done it a lot, will do it some more.
Wayne
Hello,
I have this simple program to offer. Hope it can help.
#include <cstdlib>
#include <iomanip> //..setprecision ect
#include <iostream>
using namespace std;
struct alphaDom
{
double st_cap;
double st_han;
double st_kop;
double networkNumber();
};
int main()
{
cout.setf(ios::fixed);
alphaDom NalphaDom = { 103.498, 206.998, 302.986 };
alphaDom* palphaDom = &NalphaDom;
cout << endl
<< "networkNumber is " << setprecision(3) <<palphaDom->networkNumber() << endl << endl;
system("PAUSE");
return 0;
}
double alphaDom::networkNumber()
{
return st_cap * st_han * st_kop;
}