"john v." <transpsyche@yahoo.com> wrote:
>
>thx. yeah i know a char pointer isnt needed, just wanted to know why it

wouldnt
>work.
>
>"DoesItMatter" <doesitmatter@doesitmatter.com> wrote:
>>
>>Allocate space for the pointer
>>
>>
>>"James Curran" <jamescurran@mvps.org> wrote:
>>> What exactly are you trying to do? You seem to be using a char pointer
>>>where you want a simple char:
>>> class X
>>>{
>>> private:
>>> char ch;
>>> public:
>>> void getchar() { cin>>ch; };
>>> };
>>>
>>>
>>>--
>>>Truth,
>>>James Curran
>>>http://www.NJTheater.com
>>>http://www.NJTheater.com/JamesCurran
>>>
>>>
>>>
>>>"john v." <transpsyche@yahoo.com> wrote in message
>>>news:38c8fb31$2@news.devx.com...
>>>>
>>>> hi, having run-time errors this code, altho it does compiled ok, probably
>>>> a syntax error, please help?!
>>>>
>>>> class X{
>>>> private: char *ch;
>>>>
>>>> file://some defs and member funcs....
>>>>
>>>> public:
>>>> void getchar() { cin>>*ch; }; file://is this allowed, if not
>>>> file://whats an alternative?
>>>> };
>>>>
>>>> thx
>>>>
>>>
>>>

The reason for runtime errors is that you have defined a character pointer
or string constant but not assigned a value to it at compile as you should
do but left it to runtime with the cin command. If you want to do that with
classes you need to employ the scope resolution operator as:-

X::ch="Software rules ok";
in your implentation file
Alternatively use an array of characters to store your input string and avoid
runtime errors generated by null pointers assignments.


>>

>