answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

Declare a class called string - it must have constructors which allow definitions of objects in the following form - string name1 string name2minu string name3name2 in cpp?

There's no need to create a class to do this as std::string already does this and a lot more besides. The following class will do exactly as you've asked, but it's really just a wrapper for a std::string and achieves absolutely nothing. #include<iostream> class string{ public: string(std::string s=""):m_str(s){} string(const string& s):m_str(s.m_str){} const std::string& get_string(){return(m_str);} private: std::string m_str; }; int main() { string name1; string name2("minu"); string name3(name2); std::cout << "name1 = '" << name1.get_string().c_str() << "'" << std::endl; std::cout << "name2 = '" << name2.get_string().c_str() << "'" << std::endl; std::cout << "name3 = '" << name3.get_string().c_str() << "'" << std::endl; return(0); } Output: name1 = '' name2 = 'minu' name3 = 'minu'


C plus plus program to count digit in a string?

Use the following function to count the number of digits in a string. size_t count_digits (const std::string& str) { size_t count = 0; for (std::string::const_iterator it=str.begin(); it!=str.end(); ++it) { const char& c = *it; if (c>='0' && c<='9'); ++count; } return count; }


How do you close a string literal?

Just as you have started it. good examples: 'string' "string" `string` »string« bad examples: 'string" "string` »string'


1 Define a class in C plus plus to store following information of books Title Author Publisher Price?

class Book { public: Book(std::string title, std::string author, std::string publisher, double price) : m_title(title), m_author(author), m_publisher(publisher), m_price(price) {} std::string get_title()const{return(m_title);} std::string get_author()const{return(m_author);} std::string get_publisher()const{return(m_publisher);} int get_price()const{return(m_price);} private: std::string m_title; std::string m_author; std::string m_publisher; double m_price; }


Why strcat(string'!') not work in C program?

The strcat() function has the following protocol:char* strcat (char* destination, char* source);The function appends the source string to the destination string and returns the destination string.The destination string must be a null-terminated character array of sufficient length to accommodate strlen (source) plus strlen (destination) characters, plus a null-terminator. The existing null-terminator and subsequent characters of destination are overwritten by characters from the source string, up to and including the source string's null-terminator.strcat (string, '!') will not work because '!' is a character literal (ASCII code 33 decimal), not a null-terminated character array. Use "!" instead of '!'.Example:char string[80]; // character arraystrcpy (string, "Hello world");strcat (string, "!");puts (string);

Related Questions

What are some simple techniques for creating string art?

Some simple techniques for creating string art include hammering nails into a board in a pattern, wrapping string around the nails to create designs, and experimenting with different colors and thicknesses of string for varied effects.


What are some popular techniques and patterns for creating string art in macrame?

Some popular techniques and patterns for creating string art in macrame include the square knot, half knot, and spiral patterns. These techniques involve using different knots and weaving methods to create intricate designs and textures in the string art.


What are the best techniques for playing the 1st string on a guitar?

The best techniques for playing the 1st string on a guitar involve using your fingertips to pluck the string, keeping your hand and wrist relaxed, and practicing proper finger placement and control to produce clear and precise notes.


What are the best techniques for playing the first string on a guitar?

The best techniques for playing the first string on a guitar involve using your fingertips to pluck the string, keeping your hand and wrist relaxed, and practicing proper finger placement and pressure to produce clear and crisp notes.


What are the best techniques for playing 7 string metal guitar?

The best techniques for playing 7-string metal guitar include mastering palm muting, alternate picking, string skipping, and using the low B string for heavy riffs and extended range. Practice regularly and focus on precision and speed to improve your skills.


What are some techniques for playing the high E string on the guitar?

To play the high E string on the guitar, you can use techniques such as picking with your fingers or a pick, using hammer-ons and pull-offs, and practicing proper finger placement and pressure on the fretboard. Experimenting with different techniques and finding what works best for you can help improve your playing on the high E string.


What are the best techniques for playing metal on a 7-string guitar?

The best techniques for playing metal on a 7-string guitar include palm muting, alternate picking, string skipping, and using drop tunings like drop A or drop G. Experimenting with different scales and modes can also enhance your metal playing on a 7-string guitar.


What are the best techniques for playing the b string on a guitar?

The best techniques for playing the B string on a guitar involve using proper finger placement, applying the right amount of pressure, and practicing regularly to improve accuracy and tone.


What are the best techniques for playing the top string of a guitar?

The best techniques for playing the top string of a guitar include using proper finger placement, applying consistent pressure, and practicing regularly to build strength and dexterity in your fingers.


Which of the following is the highest voice in a string quartet?

violin


What are some creative techniques for making string art crafts?

Some creative techniques for making string art crafts include using different colored strings, experimenting with different patterns and designs, incorporating beads or other embellishments, and trying out different types of string or thread for varied textures and effects.


What does the term "2fr" mean in guitar playing techniques?

The term "2fr" in guitar playing techniques refers to playing a note on the second fret of a string.