Help

Started by
7 comments, last by Johnny_Blaze93 21 years, 8 months ago
Anyone know what this error might indicate: C:\WINDOWS\Desktop\linkedlists\main.cpp(50) : error C2501: ''String_Temp'' : missing storage-class or type specifiers ???
I OWN YOU
Advertisement
Probably either have mistyped the type name, or haven''t included the proper header for that type. What''s the line look like?
its in a global struct:
struct SLinkedList{

Element *First_Element;
Element *Last_Element;
char *String_Temp;
String_Temp = /*new char*/ 0;

long number;
Element *Element_Temp;



} *linkedlist;

and it points to the line were it says:
String_Temp = /*new char*/ 0;
i have no idea :S
I OWN YOU
What are you trying to do in the line "String_Temp = /*new char*/ 0;"? Can''t remember exactly, but I don''t believe you''re going to be able to initialize String_Temp inside of the struct like that. Instead, consider a constructor for it:


  struct SLinkedList{    Element *First_Element;    Element *Last_Element;    char *String_Temp;    long number;    Element *Element_Temp;    SLinkedList ( void )    {        String_Temp = 0;    }} *linkedlist;  

String_Temp = /*new char*/ 0;

This is an executable line. It can''t go in a structure definition. If you want it to default to NULL you have to initialize it in a function someplace
Joshua Barczak3D Application Research GroupAMD
If you want to initialize a variable in the structure to zero and you''re using C++ you can use a constructor.
I don''t know 100% for sure, but I believe it''s done like this:


  struct SLinkedList{    SLinkedList():    String_Temp = 0;    {}    Element *First_Element;    Element *Last_Element;    char *String_Temp;    long number;    Element *Element_Temp;    SLinkedList ( void )    {        String_Temp = 0;    }} *linkedlist;  


Try it out and tell me(Not compiler ATM to test it myself)

*** Timeout Error ***

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.


My Site
----------------(Inspired by Pouya)
quote:Original post by Johnny_Blaze93
its in a global struct:
struct SLinkedList{

Element *First_Element;
Element *Last_Element;
char *String_Temp;
String_Temp = /*new char*/ 0;

long number;
Element *Element_Temp;



} *linkedlist;

and it points to the line were it says:
String_Temp = /*new char*/ 0;
i have no idea :S


One other thing that hasn''t been mentioned, you can''t modify the value of String_Temp to 0 like you''re doing, that will make the String_Temp point to the system''s memory address 0.

"DaHjajmajQa''jajHeghmeH!"

Cyberdrek
danielc@iquebec.com
Founder
Laval Linux

/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash
[Cyberdrek | ]
Cyberdrek: Yes you can. 0 also indicates NULL pointer, or in other words, a pointer that is not in use.

Sand_Hawk: That won''t work.

What Melraidin wrote would work. But it doesn''t assign the value of pointer in construction phase.. Instead, this does:

struct Blah{   char *String_Temp   Blah() : String_Temp(0) {}}; 

This topic is closed to new replies.

Advertisement