You probably meant:
c_info[i].hoursWorked;
since c_info
is an array, by doing c_info[i]
you’ll access the i
-th instance (object) of Employee
class in c_info
array, and then obtain hoursWorked
through .
operator.
Now you can clearly see that your variant simply doesn’t make sense, as hoursWorked
is just an integral type and not an array, and therefore you cannot apply []
operator to it.
Related Posts:
- What are the differences between a pointer variable and a reference variable in C++?
- Return array in a function
- Struct Constructor in C++?
- What does “dereferencing” a pointer mean?
- Regular cast vs. static_cast vs. dynamic_cast
- C++ struct constructor
- What is a smart pointer and when should I use one?
- What does “dereferencing” a pointer mean?
- What is a char*?
- What exactly is nullptr?
- How to fix a “invalid operands to binary expression” error?
- What is a dangling pointer?
- What does `*&` in a function declaration mean?
- (->) arrow operator and (.) dot operator , class pointer
- What is uintptr_t data type
- What is the difference between const int*, const int * const, and int const *?
- C++ – No matching member function for call to ‘push_back’
- What is uintptr_t data type
- What does int & mean
- What is the difference between const int*, const int * const, and int const *?
- Pointer to incomplete class type is not allowed
- Vector of structs initialization
- Passing a 2D array to a C++ function
- error: expected primary-expression before ‘)’ token (C)
- Can’t resolve Error: indirection requires pointer operand (‘int’ invalid)
- How to create a dynamically-allocated array of const objects, but have values assigned to them?
- What are the differences between struct and class in C++?
- How to access the contents of a vector from a pointer to the vector in C++?
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- What does int & mean
- C++: Expression must have a constant value when declaring array inside function
- Sorting Linked List C++ with pointers
- Delete 2D array C++
- Is the sizeof(some pointer) always equal to four?
- C++ strings and pointers
- initial value of reference to non-const must be an lvalue
- Typedef function pointer?
- How to initialize a vector of pointers
- What is the use of intptr_t?
- Difference between ‘struct’ and ‘typedef struct’ in C++?
- error: expected unqualified-id before ‘.’ token //(struct)
- C++ – Assigning null to a std::string
- Function for C++ struct
- error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- Using C-string gives Warning: “Address of stack memory associated with local variable returned”
- Reference to non-static member function must be called
- Why use pointers?
- What’s the difference between * and & in C?
- How to return a struct from a function in C++?
- C++ pass an array by reference
- Function stoi not declared
- C++ Array of pointers: delete or delete []?
- Why should I use a pointer rather than the object itself?
- too many initializers for ‘int [0]’ c++
- Function stoi not declared
- C++ correct way to return pointer to array from function
- Warning: comparison of distinct pointer types
- Struct inheritance in C++
- Initializing pointers in C++
- Difference between function arguments declared with & and * in C++
- Is C++ Array passed by reference or by pointer?
- Difference between the int * i and int** i
- set head to NULL (‘NULL’ : undeclared identifier)
- What is a `char*`?
- clearing a vector of pointers [duplicate]
- Struct with template variables in C++
- C++ Swapping Pointers
- Array of Linked Lists C++
- Differences between unique_ptr and shared_ptr
- Floating point exception( core dump
- Passing Arrays to Function in C++
- How does the modulus operator work?
- Single class has a Class Redefinition Error
- Identifier not found error on function call
- Debug assertion failed. C++ vector subscript out of range
- What causes a SIGABRT fault?
- Graphics Library for C++
- Socket Programming in C++
- warning: ISO C++ forbids variable length array
- cin >> “no operator matches these operands”
- C++ Structure Initialization
- C++ #include guards
- glm rotate usage in Opengl
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- cannot declare variable ‘’ to be of abstract type ‘’
- How to call on a function found on another file?
- How to project a point onto a plane in 3D?
- generate random double numbers in c++
- Cygwin Make bash command not found
- C++ Compiler Error C2280 “attempting to reference a deleted function” in Visual Studio 2013 and 2015
- Class template inheritance C++
- C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’
- Two decimal places using printf( )
- error C2244 unable to match function definition to an existing declaration
- Static vs dynamic type checking in C++
- What does “warning: not all control paths return a value” mean? (C++)
- Is it still safe to delete nullptr in c++0x?
- Declaration is incompatible with type
- One or more multiply defined symbols found
- I’m getting the error “stoi is not a member of std” in myprogramminglab [duplicate]