Thread: Expected primary expression

  1. #1
    Village id10t
    Join Date
    May 2008
    Posts
    57

    Expected primary expression

    Code:
    void compare(WeatherReport Report);
    .
    .
    .
    for(i=0;i<DAYS;i++)
    {
    WeatherReport.compare(MonthlyReport[i]);
    }
    .
    .
    .
    void WeatherReport::compare(WeatherReport Report)
    {
    WeatherReport WeatherSummary;
    
    if (Report.HighTemp>WeatherSummary.HighTemp)
    	WeatherSummary.HighTemp=Report.HighTemp;
    	
    if (Report.LowTemp<WeatherSummary.LowTemp)
    	WeatherSummary.LowTemp=Report.LowTemp;
    		
    if (Report.AmountRain>WeatherSummary.AmountRain)
    	WeatherSummary.AmountRain=Report.AmountRain;
    	
    if (Report.AmountSnow>WeatherSummary.AmountSnow)
    	WeatherSummary.AmountSnow=Report.AmountSnow;
    	
    cout<<WeatherSummary;	
    
    }
    Hey everyone, I am having a hell of at time with arrays of classes. In this case i want to send MothlyReport to WeatherReports compare member but I get the following error message : "Expected primary expression before ." that is in the WeatherReport.compare(MonthlyReport[i]) Can anyone please guide me?
    Thanks

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Shouldn't that be Report.compare(...)?

    Also, you might want to pass these arguments by const reference.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    17
    Quote Originally Posted by MarlonDean View Post
    Code:
    for(i=0;i<DAYS;i++)
    {
    WeatherReport.compare(MonthlyReport[i]);
    }
    Is that for loop inside the definition of compare(), or is it part of another function?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. expected primary expression before "." token
    By melodious in forum C++ Programming
    Replies: 4
    Last Post: 07-11-2007, 04:39 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM