Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: Turn off level in View, C++

$
0
0

[quote user="HDR_Coder"]Why couldn't I dereference my pointer later in the code?[/quote]

I assume that you mean deallocate?

Because, as you've demonstrated, it's easy to forget to delete something that was allocated elsewhere.

[quote user="HDR_Coder"]delete levelName;[/quote]

Also, as you demonstrate, it's easy to use the wrong delete.  You allocate the string using the [] version of new, so you must delete [].

delete [] levelName;

If you use std::wstring, you don't have to allocate memory, nor do you have to remember to deallocate later.  And there's no opportunity to use the wrong deleter.

[quote user="HDR_Coder"]I was not aware that MicroStation treats a char * like a wchar_t*[/quote]

Not quite sure what you mean.  char is usually 8-bits to store ASCII characters, wchar_t is usually 16-bits to store Unicode characters.  They are different types, so nothing — including MicroStation — 'treats a char * like a wchar_t*'.


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>