Question Answer Forum

"c++ Programming" Topic Questions


How to tf2 (C++ Programming Language)

Answer

1 hats . Source: Tutorials .....

How to Write a C++ program using class and objects. You have to define multiple-member functions outside class and all those functions will be the same name (C++ Programming Language)

Answer

1 #include <iostream> 2 ​ 3 using namespace std ; 4 ​ 5 class Box { 6 public : 7 double length ; // Length of a box 8 double breadth ; // Breadth of a box 9 double height ; // Height of a box 10 ​ 11 // Member functions declaration 12 double getVolume ( void ); 13 void setLength ( double len .....

How to what is blob in computer vision (C++ Programming Language)

Answer

1 In Image processing , blob detection refers to modules that are aimed at detecting points and / or regions in the image that differ in properties like brightness or color compared to the surrounding Source: Code .....

How to how to append one vector to another c++ (C++ Programming Language)

Answer

1 vector < int > a ; 2 vector < int > b ; 3 // Appending the integers of b to the end of a 4 a . insert ( a . end (), b . begin (), b . end ()); Source: .....

How to flowchart to display factors of a number (C++ Programming Language)

Answer

1 #include<iostream> 2 using namespace std ; 3 int main () { 4     int num = 20 , i ; 5     cout << "The factors of " << num << " are : " ; 6     for ( i = 1 ; i <= num ; i ++ ) { 7       if ( num % i == 0 ) 8     .....

How to how to make string get spaces c++ (C++ Programming Language)

Answer

1 string s ; 2 getline ( cin , s ); Source: Code .....

How to c++ header files example (C++ Programming Language)

Answer

1 //headers 2 #ifndef TOOLS_hpp 3 #define TOOLS_hpp 4 #include<vector> 5 #include<iostream> 6 #include<fstream> 7 #include<string> 8 using std :: ifstream ; 9 using std :: cout ; 10 using std :: cin ; 11 using std :: endl ; 12 using std :: cerr ; 13 using std :: vector ; 14 .....

How to c++ remove class from vector (C++ Programming Language)

Answer

1 #include <algorithm> 2 #include <vector> 3 #include <iostream> 4 ​ 5 class MyClass 6 { 7 public : 8 std :: string Name ; 9 }; 10 ​ 11 std :: vector < MyClass > MyClass_Vector ; 12 ​ 13 int main () 14 { 15 MyClass myclass_1 ; 16 MyClass myclass_2 ; 17 MyClass myclass_3 ; 18 .....

How to c++ shared pointer operator bool (C++ Programming Language)

Answer

1 #include <iostream> 2 #include <memory> 3   4 void report ( std :: shared_ptr < int > ptr ) { 5 if ( ptr ) { 6 std :: cout << "*ptr=" << * ptr << "\n" ; 7 } else { 8 std :: cout << "ptr is not a valid pointer.\n" ; 9 } 10 } 11   12 int main () { .....

How to template member functions in cpp files (C++ Programming Language)

Answer

1 template < class T > 2 void foo < T > :: bar ( const T & t ) 3 { } 4 // Explicit template instantiation 5 template class foo < int > ; Source: .....

How to hashtable linear probing ,insertion deletion searching (C++ Programming Language)

Answer

1 //all the basic opertaion insertion , deletion ,searching,displaying 2 #include <iostream> 3 ​ 4 using namespace std ; 5 void init ( int arr [], int size ) 6 { 7 for ( int i = 0 ; i < size ; i ++ ) 8 { 9 arr [ i ] =- 1 ; 10 } 11 } 12 void inserthash ( int arr [], int size , int value ) .....

How to Arrays hackerrank solution in c++ (C++ Programming Language)

Answer

1 #include <cmath> 2 #include <cstdio> 3 #include <vector> 4 #include <iostream> 5 #include <algorithm> 6 using namespace std ; 7 ​ 8 ​ 9 int main () { 10 /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 11 int n , i = 0 ; 12 cin >> n ; .....

How to C++ and endl (C++ Programming Language)

Answer

1 // endl example 2 #include <iostream> // std::cout, std::end 3 using namespace std ; 4 int main () { 5 ​ 6 int a = 100 ; 7 double b = 3.14 ; 8 ​ 9 cout << a ; 10 cout << endl ; // manipulator inserted alone 11 cout << b << endl << a * b ; // manipulator in .....

How to allocate memory c (C++ Programming Language)

Answer

1 // Use malloc to allocate memory 2 ptr = ( castType * ) malloc ( size ); 3 int * exampl = ( int * ) malloc ( sizeof ( int )); 4 // Use calloc to allocate and inizialize n contiguous blocks of memory 5 ptr = ( castType * ) calloc ( n , size ); 6 char * exampl = ( char * ) calloc ( 20 , sizeof ( .....

How to MPI_file_open (C++ Programming Language)

Answer

1 #include <mpi.h> 2 int MPI_File_open ( MPI_Comm comm , const char * filename , 3 int amode , MPI_Info info , 4 MPI_File * fh ) 5 //MPI_File_open opens the file identified by the filename filename on all 6 //processes in the comm communicator group. 7 //MPI_File_open is a collective routine; .....

How to undefined reference to instance (C++ Programming Language)

Answer

1 //Put this in the .cpp 2 Singleton * Singleton :: instance = NULL ; 3 //! This is the Singleton definition in .hpp 4 class Singleton { 5 private : 6 static Singleton * instance ; 7 8 public : 9 static Singleton * getInstance () { 10 if ( instance == NULL ) { instance = new Singleton ; } 11 return .....

How to android emulator wifi connected without internet (C++ Programming Language)

Answer

1 May be a VPN problem , disconnect from it 2 On Windows 3 Open Network and Sharing Center and click on current Connection 4 Click on Properties 5 Double Click on Internet Protocol Version 4 ( TCP / IPv4 ) 6 Set the Preferred and Alternate DNS servers as ( Screenshot below ) : 7 8.8.8.8 8 8.8.4.4 9 .....

How to how to show constellations in starry night orion special edition (C++ Programming Language)

Answer

1 Press K to toggle constellations on or off . Source: Code .....

How to powershell script to get uptime of multiple servers (C++ Programming Language)

Answer

1 Function Get - Uptime { 2 < # 3 . Synopsis 4      This will check how long the computer has been running and when was it last rebooted . 5      For updated help and examples refer to - Online version . 6   7   8 . NOTES 9 .....

How to cpp get screen resolution (C++ Programming Language)

Answer

1 #include "wtypes.h" 2 #include <iostream> 3 using namespace std ; 4 ​ 5 // Get the horizontal and vertical screen sizes in pixel 6 void GetDesktopResolution ( int & horizontal , int & vertical ) 7 { 8 RECT desktop ; 9 // Get a handle to the desktop window 10 const HWND hDesktop = .....

How to define for loop c++ (C++ Programming Language)

Answer

1 #define FOR(x,a,b) for(int x = a; x <= b; x++) 2 #define FOD(x,a,b) for(int x = a; x >= b; x--) 3 #define REP(x,a,b) for(int x = a; x < b; x++) 4 #define RED(x,a,b) for(int x = a; x > b; x--) Source: Tutorials .....

How to columntransformer onehotencoder (C++ Programming Language)

Answer

1 from sklearn . compose import ColumnTransformer 2 from sklearn . preprocessing import OneHotEncoder Source: .....

How to num c++ (C++ Programming Language)

Answer

1 #include <iostream> 2 using namespace std ; 3 4 int main () { 5 // number definition: 6 short s ; 7 int i ; 8 long l ; 9 float f ; 10 double d ; 11 12 // number assignments; 13 s = 10 ; 14 i = 1000 ; 15 l = 1000000 ; 16 f = 230.47 ; 17 d = 30949.374 ; 18 19 // number printing; 20 cout .....

How to union cpp (C++ Programming Language)

Answer

1 union S 2 { 3 std :: string str ; 4 std :: vector < int > vec ; 5 ~ S () {} // needs to know which member is active, only possible in union-like class 6 }; // the whole union occupies max(sizeof(string), sizeof(vector<int>)) 7   Source: Code .....

How to move letter position using c++ with input (C++ Programming Language)

Answer

1 #include <iostream> 2 ​ 3 using namespace std ; 4 ​ 5 int main () 6 { 7 char c = 'x' ; 8 int position = 0 ; //starts from the left most position 9 int temp = 0 ; 10 cout << "*" << endl ; 11 cout << "Enter: l (Move Left) or r (Move Right) or x (exit): " << endl ; 12 .....

How to bubble sort (C++ Programming Language)

Answer

In the bubble sort technique, each of the elements in the list is compared to its adjacent element Thus if there are n elements in list A, then A[0] is compared to A[1], A[1] is compared to A[2] and so on After comparing if the first element is greater than the second, the two elements are swapped .....

How to Implement two clique problem (C++ Programming Language)

Answer

1 // C++ program to find out whether a given graph can be 2 // converted to two Cliques or not. 3 #include <bits/stdc++.h> 4 using namespace std ; 5    6 const int V = 5 ; 7    8 // This function returns true if subgraph reachable from 9 // src is Bipartite or not. 10 bool .....

How to char c++ (C++ Programming Language)

Answer

1 isdigit () - Check if character is decimal digit 2 isalpha () - Check if character is alphabetic 3 isblank () - Check if character is blank 4 islower () - Check if character is lowercase letter 5 isupper () - Check if character is uppercase letter 6 isalnum () - Check if character is alphanumeric .....

How to count digits c++ (C++ Programming Language)

Answer

1 template < class T > 2 T countDigits ( T number ) 3 { 4 return T ( log10 ( number ) + 1 ); 5 } 6 //If the number is very large, use string Source: Geeks For Geeks Source: .....

How to function return with int c++ (C++ Programming Language)

Answer

1 #include <iostream> 2 3 int getValueFromUser () 4 { 5 std :: cout << "Enter an integer: " ; 6 int input {}; 7 std :: cin >> input ; 8 9 return input ; 10 } 11 12 int main () 13 { 14 int x { getValueFromUser () }; // first call to getValueFromUser 15 int y { getValueFromUser () .....

How to c++ change console color (C++ Programming Language)

Answer

1 WORD color = 0x0F ; // White 2 SetConsoleTextAttribute ( GetStdHandle ( STD_OUTPUT_HANDLE ), FOREGROUND_RED ); 3 cout << Hello World << endl ; 4 SetConsoleTextAttribute ( GetStdHandle ( STD_OUTPUT_HANDLE ), color ); 5 // The farbcodes are the same as they, when you type color help in .....

How to list stl (C++ Programming Language)

Answer

1 template < class T , class Alloc = allocator < T > > class list ; Source: Tutorials .....

How to Function Template with multiple parameters (C++ Programming Language)

Answer

1 #include <iostream> 2 using namespace std ; 3 ​ 4 template < class TFirst , class TSecond > 5 ​ 6 //returns smaller number 7 TFirst smaller ( TFirst A , TSecond B ) { 8 ​ 9 return ( A < B ? A : B ); //if A is less then B then return A; if not, return B 10 } 11 ​ 12 int main () { 13 .....

How to top view of binary tree c++ (C++ Programming Language)

Answer

1 // C++ Program to print Top View of a binary Tree 2 ​ 3 #include <iostream> 4 #include <queue> 5 #include <stack> 6 using namespace std ; 7 ​ 8 // class for Tree node 9 class Node { 10 public : 11 Node * left , * right ; 12 int data ; 13 Node () { left = right = 0 ; } 14 Node ( .....

How to function in struct c++ (C++ Programming Language)

Answer

1 struct foo { 2 int bar ; 3 foo () : bar ( 3 ) {} //look, a constructor 4 int getBar () 5 { 6 return bar ; 7 } 8 }; 9 foo f ; 10 int y = f . getBar (); // y is 3 Source: StackOverFlow Source: .....

How to c++ find object in vector by attribute (C++ Programming Language)

Answer

1 std :: vector < Type > v = ... .; 2 std :: string myString = ... .; 3 auto it = find_if ( v . begin (), v . end (), [ & myString ]( const Type & obj ) { return obj . getName () == myString ;}) 4 if ( it != v . end ()) 5 { 6 // found element. it is an iterator to the first matching .....

How to Priority Queue using Min Heap in c++ (C++ Programming Language)

Answer

1 #include <bits/stdc++.h> 2 using namespace std ; 3 4 ​ 5 int main () 6 { 7 8 priority_queue < int > pq ; 9 pq . push ( 5 ); 10 pq . push ( 1 ); 11 pq . push ( 10 ); 12 pq . push ( 30 ); 13 pq . push ( 20 ); 14 15 16 while ( pq . empty () == false ) 17 { 18 cout << pq . top () .....

How to mqtt esp32 (C++ Programming Language)

Answer

1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 .....

How to error: ‘memset’ was not declared in this scope in cpp (C++ Programming Language)

Answer

1 C : #include <string.h> 2 ​ 3 C ++ : #include <cstring> 4 ​ 5 NOTE : inclusion of above headers works fine Source: .....

How to show stack c++ (C++ Programming Language)

Answer

1 void showstack ( stack < int > s ) { 2 while ( ! s . empty ()) { 3 cout << s . top () << ; 4 s . pop (); 5 } 6 cout << endl ; 7 } Source: .....

How to char size length c++ (C++ Programming Language)

Answer

1 char * a = ABC ; 2 int length = sizeof ( a ) / sizeof ( char ); Source: .....

How to c printf (C++ Programming Language)

Answer

1 /* printf example */ 2 #include <stdio.h> 3 ​ 4 int main () 5 { 6 printf ( "Characters: %c %c \n" , 'a' , 65 ); 7 printf ( "Decimals: %d %ld\n" , 1977 , 650000 L ); 8 printf ( "Preceding with blanks: %10d \n" , 1977 ); 9 printf ( "Preceding with zeros: %010d \n" , 1977 ); 10 printf ( "Some .....

How to convert GLFWwindow* to IntPtr (C++ Programming Language)

Answer

1 // C++/CLR 2 // Convert to IntPtr 3 IntPtr ptr ( window ); 4 // Convert back to GLFWwindow* 5 ( GLFWwindow * ) ptr . ToPointer (); Source: Geeks For .....

How to how to check string contains char in c++ (C++ Programming Language)

Answer

1 std :: string s = Hello ; 2 if ( s . find ( 'e' ) != std :: string :: npos ) 3 cout << Found ; 4 else 5 cout << Not Found ; Source: .....

How to qt design editor hide window bottom white bar (C++ Programming Language)

Answer

1 // Rigth click on your window and click remove status bar Source: Tutorials .....

How to c++ vector combine two vectors (C++ Programming Language)

Answer

1 vector1 . insert ( vector1 . end (), vector2 . begin (), vector2 . end ()); Source: Tutorials .....

How to include pdf file in latex (C++ Programming Language)

Answer

1 \ includepdf [ pages =- , pagecommand = {}, width = \ textwidth ]{ file . pdf } 2 \ includepdf [ pages =- , fitpaper ]{ file . pdf } Source: .....

How to list in cpp (C++ Programming Language)

Answer

1 //code by Soumyadeep Ghosh 2 //ig: @soumyadepp 3 ​ 4 #include <bits/stdc++.h> 5 ​ 6 using namespace std ; 7 ​ 8 void display_list ( list < int > li ) 9 { 10 //auto variable to iterate through the list 11 for ( auto i : li ) 12 { 13 cout << i << " " ; 14 } 15 } 16 int main .....

How to c++ substr (C++ Programming Language)

Answer

In C++, a part of a string is referred to as a substring substr is a C++ function for obtaining a substring () There are two parameters in this function: pos and len The pos parameter defines the substring's start location, while the len indicates the number of characters in the .....