C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 21st, 2012, 10:56 AM
vishalonne vishalonne is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 16 vishalonne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 5 sec
Reputation Power: 0
Passing Array of Object gives compilation ERROR

Passing Array of Object gives compilation ERROR

Hello Everybody

This is my question
Define a class named HOUSING in C++ with the following descriptions:
Private members
REG_NO integer(Ranges 10 — 1000)
NAME Array of characters(String)
TYPE Character
COST Float
Public Members
• Function Read_Data( ) to read an object of HOUSING type
• Function Display() to display the details of an object
• Function Draw Nos( ) to choose and display the details of 2 houses selected randomly from an array of 10 objects of type HOUSING Use random function to generate the registration nos. to match with REGNO from the array.

Now I'm trying to do this by this way

Code:
      #include <iostream.h>
      #include <conio.h>
      #include <stdlib.h>
    
      class housing
      {
            private:
                int REG_NO;
                char NAME[10];
                char TYPE;
                float COST;
            public:
                void Read_Data();
                void Display();
                void DrawNos(housing);
      };
      void housing::Read_Data( )
      {
            cout<<"Enter Registration No: ";
            cin>>REG_NO;
            cout<<"Enter Name: ";
            cin>>NAME;
            cout<<"Enter Type: ";
            cin>>TYPE;
            cout<<"Enter cost: ";
            cin>>COST;
      }
      void housing::Display()
      {
      }
      void housing::DrawNos(housing* h1[])
      {
           int N=10;
           int randomREG=random(10);
           N=random(2);
           cout<<h1[N]->REG_NO;
      }
      void main()
      {     
            int i=0;
            housing* h[5];
            for(i=0;i<5;i++)
            {
                    h[i]->Read_Data();
            }
            for(i=0;i<5;i++)
            {
                    h[i].DrawNos(h); // I am trying to pass the array of object to DrawNos function but getting error
            }
      }


I am tryin to pass the entire array of object in DrawNos(). but getting comilation error -

Quote:
32: 'housing:rawNos(housing * *)' is not a member of 'housing'
48: Structure required on left side of . or .*

What is the problem? How can I pass the array of object in function and use it.

Please help me with this problem.

Reply With Quote
  #2  
Old December 21st, 2012, 11:20 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,831 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 11 h 56 m 32 sec
Reputation Power: 1774
Santa Claus makes an early start with distributing gifts here and there
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Passing Array of Object gives compilation ERROR

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap