Hi all,
Im currently working on a c++ program for school, and I thought it would be nice If i framed the output from a function. I looked all over the web to find a solution to no avail. Im completely stuck. I keep getting 2 errors:
*154:35: error: expected '(' for function-style cast or type construction
<<"| "<< (*Function)(int c) <<" |"<<endl*
and
*166:21: error: cannot take the address of an rvalue of type 'void'
Problem1Container(&LineLoop(6), choice);
^~~~~~~~~~~~*
Im not really sure how to proceed. How do I go about fixing these errors? Below is a code snippet for all the relevent code, as well as a screenshot of the code im having issue with.
Thank you!
P.S if there is any other information I should add, let me know. im fairly new to online forums.
void LineLoop(int size)
{
int x;
string line;
for(x = 0; x <= size; x++)
{
line = line + "-";
}
cout << line <<endl;
}
void Problem1Container(void (*Function) (int c) ,int choice)
{
cout
<<"*-----------Output------------*"<<endl
<<"| |"<<endl
<<"| "<< (*Function)(int c) <<" |"<<endl
<<"| |"<<endl
<<"*-----------Output------------*"<<endl;
}
void Problem1Pics(int choice)
{
string line;
if(choice == 1) //lines
{
Problem1Container(&LineLoop(6), choice);
}
screenshot: http://prntscr.com/8rs5dm