Just when I think I understand this stuff some else crops up to bite me. This part was supposed to be the easy part of the overall project so this does not bode well... What am trying to do is create an array of 32 variables that will be filled later on by another class. So all I need this class to do is initialize an array and allow me to return its values. Should be easy peasey. However; I am clearly overlooking something simple.
class Telegraph{
public:
Telegraph(){
int const size = 32;
int *telegraph = new int[size];
}
~Telegraph(){
delete[] telegraph;
}
int *telegraphValues(){
for(int i = 0; i < 32; i++){
return telegraph[i];
}
}
private:
int *telegraph[];
};
#include <iostream>
#include "Telegraph.h"
using namespace std;
int main(){
Telegraph *one = new Telegraph();
for(int i = 0; i < 32; i++){
one[i] = i;
i++;
}
cout << one->telegraphValues;
}
and these are my errors:
------ Build started: Project: TelegraphTest, Configuration: Debug Win32 ------
TelegraphTest.cpp
c:\documents and settings\dee\my documents\visual studio 2010\projects\telegraphtest\telegraphtest\telegraph.h(19): warning C4200: nonstandard extension used : zero-sized array in struct/union
Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
c:\documents and settings\dee\my documents\visual studio 2010\projects\telegraphtest\telegraphtest\telegraph.h(9): warning C4154: deletion of an array expression; conversion to pointer supplied
c:\documents and settings\dee\my documents\visual studio 2010\projects\telegraphtest\telegraphtest\telegraphtest.cpp(9): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
c:\documents and settings\dee\my documents\visual studio 2010\projects\telegraphtest\telegraphtest\telegraph.h(20): could be 'Telegraph &Telegraph::operator =(const Telegraph &)'
while trying to match the argument list '(Telegraph, int)'
c:\documents and settings\dee\my documents\visual studio 2010\projects\telegraphtest\telegraphtest\telegraphtest.cpp(12): error C3867: 'Telegraph::telegraphValues': function call missing argument list; use '&Telegraph::telegraphValues' to create a pointer to member
c:\documents and settings\dee\my documents\visual studio 2010\projects\telegraphtest\telegraphtest\telegraphtest.cpp(12): error C3867: 'Telegraph::telegraphValues': function call missing argument list; use '&Telegraph::telegraphValues' to create a pointer to member
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========