Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Sheff

@Sheff
About
Posts
6
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Expression parser. Unary minus problems :(
    S Sheff

    Hi all, I'm writing an expression parser using Baur and Zamelzon algorithm, but it seems that it can't handle unary minuses correctly :( What shall I do, does anybody know some algorithm that can parse unary minuses correctly ? Don't offer reverse notation, it has the same problem :(

    C / C++ / MFC algorithms help question

  • operator+, problems...
    S Sheff

    Oh, thank's a lot, you helped a lot. I'm writing an interpreter and I needed a specialized string class of my own, and that's the first time I hear about COPY constructor, I programmed a lot, but never heard about it, thanks a lot again :))) ...

    C / C++ / MFC help question

  • operator+, problems...
    S Sheff

    Here's my code: class CStr { private: char *buffer; public: //Construction CStr(void) { buffer=NULL; } CStr(const char *init) { if (init!=NULL) { buffer = new char[strlen(init)+1]; strcpy(buffer,init); } else buffer=NULL; } //Destruction ~CStr(void) { Empty(); } //Operations void Empty() { delete[] buffer; } //Overloads CStr& operator= (const char* val) { Empty(); if (val!=NULL) { buffer = new char[strlen(val)+1]; strcpy(buffer,val); } else buffer=NULL; return *this; } CStr operator+ (const char* val) { CStr temp; char *pBuf=new char[strlen(val)+strlen(buffer)+1]; strcpy(pBuf,buffer); strcat(pBuf,val); temp.buffer=pBuf; return temp; } CStr& operator= (const CStr val) { if (this == &val) return *this; Empty(); buffer = new char[strlen(val.buffer)+1]; strcpy(this->buffer,val.buffer); return *this; } }; I use this class like this: CStr str("Test"); printf("%s",str+"ing"); But, instead of printing Testing it returns lot's of garbage. I ran the debugger, it shows me that operator+ returns bad object :( What shall I do ???

    C / C++ / MFC help question

  • operator+, problems...
    S Sheff

    Well, yes!

    C / C++ / MFC help question

  • Initialising a items in a structure
    S Sheff

    You can use constructor in your structure like this: struct MyStructure { char blablabla[200]; MyStructure() { strcpy(this->blablabla,"Testing"); } }

    C / C++ / MFC question lounge

  • operator+, problems...
    S Sheff

    Hey, everyone, I have a problem with overloading operator+, here is the code: CStr operator+ (const char* val) { CStr temp; char *pBuf=new char[strlen(val)+strlen(buffer)+1]; strcpy(pBuf,buffer); strcat(pBuf,val); temp.buffer=pBuf; return temp; } Here buffer is a member-variable which holds string data. I don't understand why, but this method never returns concatenated strings, it returns some garbage instead. Any ideas ?

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups