Saturday, March 28, 2009

error C3861: 'xxx': identifier not found

#include<iostream>
#include<conio.h>
void main()
{
    cls();
    int x=10;
    float y=10.1f;
    char z='a';
    std::cout << "x = " << x << std::endl;
    std::cout << "y = " << y << std::endl;
    std::cout << "z = " << z << std::endl;
    _getch();

}

void cls()
{
    for(int i = 0; i < 50; i++)
        std::cout<<std::endl;
}

While compiling the above program you could get

error C3861: 'cls': identifier not found

The issue when the compiler reads from top to bottom it hasn’t found the declaration of cls() yet.

Moving the cls() function above the main should fix this.

No comments:

Post a Comment