Static Class Function?

Started by
5 comments, last by yangdh15 21 years, 10 months ago
I am almost finishing with my AIM progie.. lol actually customized auto answering machine. But at the last moment, I decide to implement everything to a class so I can upload my module to somewhere without being embarassed but little problem. I don't remember if the static class Functions would work same as static data members? just Curious.. I gotta get this thing over with. you know.. forget about apstring. lol I got lazy and decided to use the famous College Board's String file lol. Hate to keep track of chars and lazy to make a new class for my own use. oh well.. lol.. thanks guys.
  
class IMBox{
   private:
      HWND m_Handle;
      apstring m_ScreenName;
      apstring m_OriginalText;
      apstring *m_ParsedTextPointer;
      int m_MessageRecived;
      int m_CurrentMessageIndex;

      static bool m_fnRetriveText();
      static bool m_fnSendTexT(const apstring &szText);
   
   public:
      IMBox();
      IMBox(const apstring &ScreenName);
      ~IMBox();

      static apstring SendText(const apstring &szTexT);
      static apstring GetNextText();

      static apstring ParseHTML(apstring &szText, apstring &szNextCode);
      static AIMMESSAGE ParseAIM(apstring &szText);
};
   
[edited by - yangdh15 on May 30, 2002 12:03:26 PM]
Advertisement
People might be better able to help if you actually asked a question....
hehe just edited. I pressed post by accident. sorry.
but how do i upload a sorce file with a tabs??
OK:

Posting source: use or [ source ] tags.<br><b>String handling: </b> you could try std::string<br><b>Static members: </b> static methods can be called without an instance of the class, but they have no '<tt>this</tt>' pointer so you cannot use any non-static members or methods of that class.<br><br><SPAN CLASS=editedby>[edited by - Sandman on May 30, 2002 9:11:06 AM]</SPAN>
Is there any better way to implement this?
because I want to make those functions inside the class but I don't need the duplicate of the function. Should I make it a friend member function? will that help??
I am so used to old Structure style that I can't implement lots of my things as a class. I guess that's why I am practicing though.

Anyone think just leave it as regular class function is better?
If you have good understanding and knowledge of class please help.

My original code

  class IMBox{      private:      HWND m_Handle;      apstring m_ScreenName;      apstring m_OriginalText;      apstring *m_ParsedTextPointer;      int m_MessageRecived;      int m_CurrentMessageIndex;      bool m_fnRetriveText();      bool m_fnSendTexT(const apstring &szText);   public:      IMBox();      IMBox(const apstring &ScreenName);      ~IMBox();      apstring SendText(const apstring &szTexT);      apstring GetNextText();      apstring ParseHTML(apstring &szText, apstring &szNextCode);      AIMMESSAGE ParseAIM(apstring &szText);};     


or


  class IMBox{      private:      HWND m_Handle;      apstring m_ScreenName;      apstring m_OriginalText;      apstring *m_ParsedTextPointer;      int m_MessageRecived;      int m_CurrentMessageIndex;      friend bool m_fnRetriveText();      friend bool m_fnSendTexT(const apstring &szText);   public:      IMBox();      IMBox(const apstring &ScreenName);      ~IMBox();      friend apstring SendText(const apstring &szTexT);      friend apstring GetNextText();      friend apstring ParseHTML(apstring &szText, apstring &szNextCode);      friend AIMMESSAGE ParseAIM(apstring &szText);};     

Will this be better idea? I guess it's not a big deal. but just curious to learn even small things.. ( this might be a big thing. )

To Sandman:

apstring class is founded on the std::string. It has all the features of std:string and it made it easy and don't have to keep track of What I do and I can just compare strings without having to use strcmp function (which it's gonna use anyways lol) I donno just easy for me. I still include std::string and use some of its functions. (by the way Thanks for the tags. hehe )oh well apstring class is REALLY SIMPLE and i would've made myself anyways just because I hate dealing with numbers of chars. you can try downloading at www.collegeboard.com lol.. for high school students hehe..

Thanks guys.

[edited by - yangdh15 on May 30, 2002 12:17:47 PM]
quote:Original post by yangdh15
Is there any better way to implement this?
because I want to make those functions inside the class but I don''t need the duplicate of the function. Should I make it a friend member function? will that help??

Functions are never duplicated unless you write the code twice. Member function code only exists in one place, but is called on the current object (this) which maintains its own internal data.

Read up on friend functions, though. They''re nothing like you seem to think they are.

quote:
apstring class is founded on the std::string. It has all the features of std:string...

No, it doesn''t. Furthermore, it isn''t standard which means that it''s more different for you to share your code with other developers. std::string overloads ==, +, [] operators, doesn''t require you to keep track of "how many chars" (ie, internally manages sequence length and memory) and works well with all other STL constructs - streams, algorithms, etc.

Switch to it.
hehe thanks for your reply Oluseyi.
I guess I still have way to much way to go.
I am not very familiar with STL yet. Switching from C to C++ is some what hard, the writing styles I had for many years have to change. But guess what!, I am adapting lol.. Thanks for all you guys help on this. I guess I''ll change it to std::string.
I think though even apstring is not a standard class, you can use .c_str() to get characters as char data type and so on. That''s what I worked with in high school AP class lol and I am pretty used to it. But I guess I''ll still change and get used to using standard functions. dumb me.. erGs! lol..
I just gotta wrap somethings up and the auto responder''s done. Well.. I found a way to message someone, who''s blocking me and they are on, on AIM of course. Tested it worked fine. I msged someone whom I blocked LOL.. It''s pretty fun. Took me awhile. I am afraid AOL''s gonna change this feature If I throw it to the public. Oh well many other people have this probally, just proud lol that I did it. I''ll put the source up one day I guess. It''s not even a knowledge or anything that I''ve figured out but funny how it meant so much to me lol. I wish to become a programmer one day. Work with other people who has same interest in me. Pretty Excited LOL.. oh well.. too much stupid sayings of me.. Once again thanks guys for the help.

This topic is closed to new replies.

Advertisement