C++: Using stringstream in class

Asked By 0 points N/A Posted on -

If I want to use stringstream in the function of the class,what will the process become?Is it related to public or private?Do data types or header files make any kind of bugs?Need to know the fact with source code or examples.

Answered By 0 points N/A #86256

C++: Using stringstream in class


First of all you need to understand that string data type is a built in data type in C+ + libraries. String data type is used to manipulation of characters and words. String class have several functions defined in “string.h” header file.  


·         strcat( s1,s2); – appends a copy of s2 to the end of s1

·         strlen(s) ; -counts all visible characters in the string s and returns its count.

·         strcpy(s1,s2); -copies string s2 to s1

·         strcmp(s1,s2);

Please refer the following link for more details and to good string class tutorials.


In Object Oriented programming any data type can be declared in private or public .But normally if we declare it in private the security is great and it can be only accessed via a public function. It‘s extremely misleading idea to think that data types and header files can cause bugs. The most fascinating features of C++ heavily depend on these key features and many advanced programming concepts do not exists if these are not used. I think you are a beginner so improve your skills and knowledge about OOP .It ‘is very much useful in future.

The way to declare a header file depends on the IDE you are using. In net beans you should use it as

#include <string.h>.

In visual C + + and code blocks it’s safe to use #include <string> .

Login/Register to Answer

Related Questions