Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2011
    Location
    Pakistan
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    using class in C++

    i m having problem in this prog.
    please help me out.....


    #include<iostream.h>

    class Square{
    private:
    int length, weigth;

    public:
    void set_value(int a,int b)
    {
    lenght=a; weigth=b;
    }
    int Area()
    {
    return length*weigth;
    }
    };

    main()
    { int A,B;
    Square sqar1;
    cout<<"enter the value of length"<<endl;
    A=getche();
    cout<<"enter the value of weigth"<<endl;
    B=getche();
    sqar1.set_value(A,B);
    cout<<"The are is"<<sqar1.Area()<<endl;
    getch();

    }

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    ...and your question?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Nov 2011
    Location
    Pakistan
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts
    its not being compiled.....
    Whats the problem in it....?

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You didn't post what the compiler errors are. However just looking at the code I can see you misspelled a variable in your set function which is certainly causing some or all of the errors you are getting.
    OracleGuy

  • #5
    New Coder
    Join Date
    Nov 2011
    Location
    Pakistan
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts
    1. 32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

    2. G:\My practice\First_Class_Pro.cpp In function `int main()':
    3. 22 G:\My practice\First_Class_Pro.cpp `getche' undeclared (first use this function)

    (Each undeclared identifier is reported only once for each function it appears in.)

    4. 27 G:\My practice\First_Class_Pro.cpp `getch' undeclared (first use this function)

    These were the errors.
    i got in mind one thing to ask. which header file is required for getche() Function?

  • #6
    New Coder
    Join Date
    Nov 2011
    Location
    Pakistan
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts
    after adding
    #include<stdio.h>
    #include<conio.h>
    only this error is being appeared. and i have changed the spell of Variable.
    32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

  • #7
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    As the message says you are using a deprecated header. Change iostream.h to iostream like it says to do and that message will go away.
    OracleGuy

  • Users who have thanked oracleguy for this post:

    Adeel.Rekhi (01-14-2012)

  • #8
    New Coder
    Join Date
    Nov 2011
    Location
    Pakistan
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks Dear.
    I got it.....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •