answersLogoWhite

0


Best Answer

C++ already provides a string class in the C++ standard template library.

#include<iostream>

#include<string>

int main()

{

using namespace std;

string s {"Hello world!"};

cout << s << endl;

}

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the program to create a string class which stores a string value in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program in java show how different string Class construcotrs are used to create string objects?

public class Test { public static void main(String[] args){ String str = new String("Rocky"); String str1 = "Rocky"; StringBuffer sb = new StringBuffer(); sb.append("Rocky"); String str2 = new String(sb); } } Above are three commonly used ways of creating Strings. Apart from you you can also pass byte arrays and character arrays as arguments to the String constructor


What does the java new operator do?

The new keyword tells Java that you want to create a new instance of a class by invoking one of the constructors for that class.// Create a new, empty String objectString s1 = new String();// Create a new String object with a different constructorString s2 = new String("howdy");


What is string class constructors?

Hello friends...The String class supports several constructors. To create an empty String, you call the default constructor.For example,String s = new String(); Thank youIf you want CA CPT coaching in Tamil nadu kindly visit our website ksacademy


Write a program to eliminate the blanks from string 8085?

public class RemoveSpace{ public static void main(String args[]){ String str = "8085"; Sysytem.out.println(str.trim()); } } Get The Desired OutPut....


Create a program in java that will accept 2 strings and display in concatenated form?

class demo { public static void main(String[] args) { if(args.length == 2) { System.out.println(args[0] + args[1]); } else { System.out.println("Usage: demo Str1 Str2"); } }

Related questions

Java program convert the inputed words into its upper case or lower case form?

There are methods in the String class; toUppercase() and toLowerCase(). i.e. String input = "Hello!"; String upper = input.toUpperCase(); //stores "HELLO!" String lower = input.toLowerCase(); //stores "hello!" -Note: these methods are NOT modifier methods therefore the original string is still "Hello!"


What is a string in java?

An object that stores an ordered set of characters (ie. "hello"). The String class represents character strings.


Write a program in java show how different string Class construcotrs are used to create string objects?

public class Test { public static void main(String[] args){ String str = new String("Rocky"); String str1 = "Rocky"; StringBuffer sb = new StringBuffer(); sb.append("Rocky"); String str2 = new String(sb); } } Above are three commonly used ways of creating Strings. Apart from you you can also pass byte arrays and character arrays as arguments to the String constructor


Make a program to print first 20 multiples of 2 in blue j?

Create a new project and create a new class. Double click on the class and add this method: public static void main( String args[]) { for(int i=1;i&lt;=20;++i) System.out.println(Integer.toString(i*2)); }


What does the java new operator do?

The new keyword tells Java that you want to create a new instance of a class by invoking one of the constructors for that class.// Create a new, empty String objectString s1 = new String();// Create a new String object with a different constructorString s2 = new String("howdy");


What is string class constructors?

Hello friends...The String class supports several constructors. To create an empty String, you call the default constructor.For example,String s = new String(); Thank youIf you want CA CPT coaching in Tamil nadu kindly visit our website ksacademy


Short note on inheritance?

Inheritance is used object oriented program. When you create a class, you can create a child class that inherits methods and data from the parent class.


Write a program that finds greater of two strings entered by user?

public class StringLength { public static void main(String args[]) { String firstString; String secondString; System.out.println("Please enter string (group of characters) "); firstString=sc.nextString(); System.out.println("Please enter second string (group of characters) "); secondString=sc.nextString(); if(firstString&gt;secondString) { System.out.println(); //create blank line System.out.println("First String is greater than the second string"); System.out.println(); } else { System.out.println("Second string is greater than the first string"); System.out.println(); } }//closes the main method }//closes the class.


Write a program to eliminate the blanks from string 8085?

public class RemoveSpace{ public static void main(String args[]){ String str = "8085"; Sysytem.out.println(str.trim()); } } Get The Desired OutPut....


Can you write a C program to check whether a string is an IP address or not?

Use the Exception class and type converters.


Create a program in java that will accept 2 strings and display in concatenated form?

class demo { public static void main(String[] args) { if(args.length == 2) { System.out.println(args[0] + args[1]); } else { System.out.println("Usage: demo Str1 Str2"); } }


What is a example of override?

An override occurs when you create a method of the same name as the one in the parent/super class. Ex: public class A { ..... public String getName(){ } ..... } public class B extends A { ..... public String getName(){ } ..... } Here class B which is the child class of A also declares a method of the same name as in the parent class. This is overriding...