[ create a new paste ] login | about

Link: http://codepad.org/a7xIKh7i    [ raw code | output | fork ]

C++, pasted on May 28:
#include <iostream>
//#include <windows.h>
using namespace std;
 
void func1();
void func2();
 
int count; // Это глобальная переменная.
 
int main()
{
    int i; // Это локальная переменная.
 
    for(i=0; i<10; i++)
    {
        count = i * 2;
        func1();
    }
 
    system("PAUSE");
    return 0;
}
 
void func1()
{
    cout << "count: " << count; // Обращение к глобальной
                                // переменной.
    cout << '\n'; // Вывод символа новой строки.
    func2();
}
 
void func2()
{
    int count; // Это локальная переменная.
 
    for(count=0; count<3; count++) cout << '.';
}
 


Output:
1
2
3
In function 'int main()':
Line 16: error: reference to 'count' is ambiguous
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: