Thread: need a help please

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    184

    need a help please

    hello guys,

    i was just working some problem on function overloading topic, i wrote a simple program to test the topic, but i got some errors which i couldn't able to recover it, can u please tell me what the error is... here is the program and the error message

    Code:
     #include<iostream>
    
    void printdat(int, int, int, char = '\');
    using namespace::std;
    
    int main()
    {
            int mm,dd,yy;
                    
            std::cout<<"Enter the date"<<endl;
            std::cin>>dd>>mm>>yy;
            
            printdat(dd,mm,yy,'.');
            printdat(dd,mm,yy);
            return 0;
    }
    
    void printdat(int dd, int mm, int yy, char a)
    {
        std::cout<<dd<<a<<mm<<a<<yy<<std::endl;
    }
    and the error is as follow

    Code:
    1.cpp:4:37: missing terminating ' character
    1.cpp:4:37: warning: multi-character character constant
    1.cpp:5: parse error before `using'
    1.cpp:15: `dd' was not declared in this scope
    1.cpp:15: `mm' was not declared in this scope
    1.cpp:15: `yy' was not declared in this scope
    1.cpp:15: ISO C++ forbids declaration of `printdat' with no type
    1.cpp:15: `int printdat' redeclared as different kind of symbol
    1.cpp:14: previous declaration of `void printdat(...)'
    1.cpp:15: initializer list being treated as compound expression
    1.cpp:16: ISO C++ forbids declaration of `getchar' with no type
    1.cpp:17: parse error before `return'
    1.cpp: In function `void printdat(int, int, int, char)':
    1.cpp:21: `void printdat(int, int, int, char)' redeclared as different kind of 
       symbol
    1.cpp:15: previous declaration of `int printdat'
    1.cpp:15: previous non-function declaration `int printdat'
    1.cpp:21: conflicts with function declaration `void printdat(int, int, int, 
       char)'
    any help will be appreciated

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    184
    sorry its the default paramaters program

  3. #3
    Registered User Scribbler's Avatar
    Join Date
    Sep 2004
    Location
    Aurora CO
    Posts
    266
    If you want to use the \ as a character, you need to use \\.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    184
    it works fine now, thanks very much

Popular pages Recent additions subscribe to a feed