DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    38

    Question Trying to Attain Data from a previously Implemented Read File Function

    Hey guys, basically what I am trying to do is access the data from a previously created readFile function already made. I am supposed to be able to access the data and store it in my own way. Here is the readFile Function:
    Code:
    void readFile(const char filename[], Vessel **vessels, Vessel **vessels2,
            int *vesselCount, int *cellCount, int *depth)
    {
      int ID;
      Vessel *ves, *ves2;
            ifstream inf(filename);
      inf >> *cellCount >> *vesselCount >> *depth;
      ves = new Vessel[*vesselCount];
      ves2 = new Vessel[*vesselCount];
      for(int i = 0; i < *vesselCount; i++)
      {
        inf >> ID;
            inf >> ves[ID].src >> ves[ID].dest >> ves[ID].capacity;
        ves2[ID] = ves[ID];
      } // for i
    
      inf.close();
      *vessels2 = ves2;
      *vessels = ves;
    } // readFile()
    Here is the Vessel Class:

    Code:
    class Vessel
    {
     public:
            int src;
      int dest;
      int capacity;
    };  // class Vessel
    This is what I came up with(I have tried different alterations of this):

    Code:
    void getData(Vessel *vessels2)
    {
      Vessel *vessels3;
    
      *vessels3 = vessels2;//copying data to my own vessel array
      return;
    }//getData
    And when I try making, I get this error(even with different alterations I end up with this error):

    prog5]$ make
    g++ -Wall -ansi -g -c blood.cpp
    blood.cpp: In function 'void getData(Vessel*)':
    blood.cpp:8: error: no match for 'operator=' in '* vessels3 = vessels2'
    bloodRunner.h:5: note: candidates are: Vessel& Vessel::operator=(const Vessel&)
    make: *** [blood.o] Error 1

    Can anyone tell me what I am doing wrong or give me a hint as to what I should do. I am not able to change the readFile function or the Vessel Class in any way. So I know I am definitely doing something wrong.

    Thanks a lot for the help in advance!
    Last edited by Stunner; 03-14-2008 at 03:52 PM.

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    You forgot to dereference vessel2:

    *vessels3 = vessels2; //error
    *vessels3 = *vessels2; //correct
    Danny Kalev

Similar Threads

  1. Verifying data read from file
    By RPBLEA in forum Java
    Replies: 5
    Last Post: 04-18-2005, 11:13 AM
  2. How to read objects from file in a loop
    By mail2vinaybabu in forum Java
    Replies: 10
    Last Post: 02-27-2005, 01:07 PM
  3. Getting a list of files into an array
    By Scott in forum VB Classic
    Replies: 12
    Last Post: 12-21-2001, 04:21 PM
  4. calling ping thru vb
    By Michael Shutt in forum VB Classic
    Replies: 6
    Last Post: 04-05-2001, 02:25 AM
  5. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 03:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links