Hi all, I have looked around on the web all over and can't seem to get any beginner guidance on making C++ work on a Mac through Xcode 4. I am learning from C++ Without fear.. which is an awesome book and has me hooked. But I have come across a few things that I can't get to work.
The code below tells me that the line:
Code:
int print_out (int n) }
that Functions that differ only in their return type cannot be overloaded..... which I don't understand.
The other item I can't work out is it is telling me that the sum in return sum is an undeclared identifier. This is the example answer for Exercise 4.1.2.
Now they are starting to get taxing should I be looking to install Windows 7 onto a partition and code in windows? Does Xcode have too many restrictions to learn on?
Any help would be most appreciated as I am loving learning C++!
Code:
#include <iostream>
using namespace std;
// Function must be declared before being used.
void print_out(int n);
int main() {
int n;
cout << "Enter a number and press ENTER: ";
cin >> n;
print_out(n);
cout << endl;
return 0;
}
// Print-out function.
// Prints numbers from 1 to n.
int print_out(int n) {
int i;
for (i = 1; i <= n; i++) // For i = 1 to n,
{cout << i << " "; // print i
return sum;}
}
Thanks