c++ - Receiving an error when requesting members for an array -


#include <iostream> #include <fstream> #include <vector> using namespace std;  int winnings[4] = {0,0,0,0}; int* p_winnings = winnings;  void calculategame(int* p_games);  int main() {     int games[6] = {12,13,14,23,24,34};     int* p_games = games;     int favorite_team,games_played,team1,team2,score1,score2,i;     ifstream data("data11.txt");     data >> favorite_team >> games_played;     vector<int> standings(4);     (i = 0;i < 4; i++)         standings[i] = 0;     (i = 0;i < games_played;i++)     {         data >> team1 >> team2 >> score1 >> score2;         if (score1 > score2)             standings[team1 - 1] += 3;         if (score1 == score2)             standings[team1-1]++,standings[team2-1]++;         if (score1 < score2)             standings[team2-1] += 3;         (i = 0; < games.size();i++)         {             int temp1,temp2,temp;             temp = games[i];             temp2 = temp % 10;             temp /= 10;             if (temp2 == team2 && temp == team1)                 games.erase(i);         }     } } 

why when request member(like .size() or .erase() ) of array games error saying "request member __ in games of non-class type int [6]"

plain old c arrays don't have members. has no size or erase. if did want have members though, c++11 offers class called std::array<t,n> can used in case doing std::array<int, 6> games = { ... }. note std::array not have erase member function, has size member function.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -