![]() |
|
#1
|
||||
|
||||
How do I reference an undeclared object ?I have to write a program for a small spreadsheet. It's a simle one-dimensional spreadsheet with only one column (of figures, formulae).
The specification for the spreadsheet says that it should start out empty upon creation of the spreadsheet object, that there should be no cells.These cells are referenced in my source code, but since I can't declare an instance of of a cell, the compiler says that the cell object (actually a member element of it) has not been declared. But if I do declare an instance, then I'm conflicting with the job spec. How can I get around this? Can I ? How can I not create a cell for the spreadhseet yet still reference it in my source code without the compiler flagging an error ? 'Tis possible, even? Any thoughts/comments would be appreciated. BTW, does this post need any source code ?? I'm using DevC++ 4.9.9.2 Personally, I can't see how to get around it, So i've declared one instance of a cell, and am hoping the specification is wrong!! |
||||
|
#2
|
|||
|
|||
Re: How do I reference an undeclared object ?I think some source code (object definitions) would be a help... and the code you have tried and are having trouble with.
|
|
#3
|
||||
|
||||
Re: How do I reference an undeclared object ?Here's some of my source code:
CPP / C++ / C Code:
CPP / C++ / C Code:
"In function `void addinCell(int)': `value' has not been declared " "In function `void addinCell(int)': `text' has not been declared " (I used n as the index in the lines above to avoid activating an italic tag) |
|
#4
|
|||
|
|||
Re: How do I reference an undeclared object ?My guess would be that since "addinCell" is not a member function and has no "this" pointer. You are going to have to pass in "cell" or make "cell" have global scope.
|
|
#5
|
||||
|
||||
Re: How do I reference an undeclared object ?Thanks, but cell already is a global variable.
|
|
#6
|
|||
|
|||
Re: How do I reference an undeclared object ?Quote:
CPP / C++ / C Code:
...did you forget that you declared cell as a pointer type? cell[i]->value cell[i]->text :davis: |
|
#7
|
||||
|
||||
Re: How do I reference an undeclared object ?Hmm, Im not sure what's happening. I originally had
temp[n].value = cell[n]->value and got an error with it. I had to change it to dot notation to get it to compile. BUt now when I have it in dot notation it doesn't compile any more, but it does if I go back to using arrows!! I must have changed something. So somehow or other it seems that my problem is solved Thanks for your thoughts. |
|
#8
|
|||
|
|||
Re: How do I reference an undeclared object ?Quote:
CPP / C++ / C Code:
...you declared temp to be a pointer type, too! struct ssCell* temp = new ssCell[row+1]; :davis: |
|
#9
|
||||
|
||||
Re: How do I reference an undeclared object ?I've changed the code for that function, and it compiles OK. It's now
CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
So just what is the difference between cell and temp? What I'm trying to do with the function is add on cells. I have N cells already existing and I want to increase that up to row+1 cells. cell is supposed to be an array of pointers only, that then get to point at new instances of ssCell as they are (dynamically) created. I know that's not what I've got. I'm still working on it |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| G++ question... | TreyAU21 | C++ Forum | 10 | 24-Feb-2006 09:45 |
| How to interpret characters as they are being entered? | nkhambal | C Programming Language | 18 | 14-Feb-2006 11:41 |
| c++ inheritance | illbemissingu | C++ Forum | 14 | 23-Oct-2005 18:35 |
| Can enum have same name as class? | crystalattice | C++ Forum | 3 | 08-Dec-2004 17:43 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 08:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The