As you guys might have guessed form the threads name, I have a few questions that am going to post under one thread because i don't want to stuff the front page...thanks in advance.

1. Why are function prototypes mostly declared before the main(), but the actual function is under the main()?
Example:

int FindArea(int length, int width); 
int main()
{
some code...
}

int FindArea(int length, int width)
{
   function code...
}

2. When passing a value to a function why wont this work:

string fileName = "text.txt";
infile.open(fileName);

3. Can the solution for this be used in any other function?
4. Would advanced C++ make a strong foundation for learning other languages?

Prototypes must come before any function that will make use of the prototyped functions. The purpose of the prototype is to ....

(I had more of an answer here, but now you should do some work on the rest of your homework on your own.)

see ,function prototypes basically tells the compiler what all functions are there in the program.in case you type the whole function before main then, you dont need to put a function prototype.
like eg.

#include< >
void func()
{
---------
-------
-------
------
}
void main()
{
------
------
----
}

here you dont need a prorotype
but
if
void main()
{
_----------
------------
--------
}
void func()
{
-----
------
------
}
you should put a function prototype so that the complier knows there is a function coming up

FYI .. void main() is never to be used !

It should always be

int main(){

  return 0;
}

See here

1. In C++ we must declare all names before using. From the C++ Standard:

Declarations specify how names are to be interpreted.

Function prototype is the most common form of function name declaration. Function header + function body called function definition. A definition is a declaration too. So you must place the function prototype or the function definition before use it.
2. The open() member function wants const char* (not string) argument. So you might correct this situation with string class member function c_str():

string fileName = "text.txt";
infile.open(fileName);string fileName = "text.txt";
infile.open(fileName.c_str()); 
// Returns const char* pointer to C-string like string contents
// It's funny but you can use the string literal "text.txt" directly:
infile.open("text.txt"); // string literal type is const char*

3. The solution ...of what?...
4. Download and read the article by B.Stroustrup, the C++ language creator:
http://www.research.att.com/~bs/new_learning.pdf

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.