[Solved] How can we serialize or deserialize the object of a class in c++.Is there any predefined library? [closed]

There is no serialization library defined as part of the C++ standard. You will have to use a third party library (and requests for recommendations are off-topic for Stack Overflow), or you will have to write your own (and “how should I write a serialization library?” is probably “too broad”). solved How can we serialize … Read more

[Solved] Understanding stringstream [closed]

There’s a constructor for std::stringstream that takes a std::string as a parameter and initializes the stream with that value. #include <iostream> #include <sstream> #include <string> int main() { std::stringstream ss(“foo bar”); std::string str1, str2; ss >> str1 >> str2; std::cout << “str1: ” << str1 << std::endl; std::cout << “str2: ” << str2 << std::endl; … Read more

[Solved] Undefine reference of

The problem is that c++ test.cpp -I./include-core/ -o bin/test -L./bin -l${core_NAME_ROOT}c++ test.cpp -I./include-core/ -o bin/test -L./bin -l${core_NAME_ROOT} will first process the library and then your .cpp file. When processing a library, referenced symbols are resolved (“linked”) and all unresolved symbols in the library that aren’t needed are thrown away. That means that as soon as … Read more

[Solved] Passing a std::pair templated with two template arguments as a parameter [closed]

When two “>” characters are near each other, they need a space in between so that it is not interpreted as the “>>” operator. After doing that change, the prototype compiles. #include <iostream> #include <vector> #include <iostream> template <typename T, typename Q> std::vector<std::pair<T, Q> > sortPairIntoVector( std::pair<T,Q>, std::vector<std::pair<T, Q> >); template <typename T, typename Q> … Read more

[Solved] CreateThread() does not work [closed]

You didn’t post any minimal compiling code we can help you debug, so, everything I’m about to say are guesses based on other questions I’ve seen on this topic: make sure asd is declared static, CreateThread is a C function and knows nothing about class methods make sure asd is declared __stdcall, having wrong calling … Read more

[Solved] randomize numbers without any std- function

I found similar question on stackoverflow : How do I generate random numbers without rand() function? I make little modifications for generating between 0-35 and final solution: #include<stdio.h> #include<time.h> int main() { int num = 36; time_t sec; sec=time(NULL); for(;;) { sec=sec%3600; if(num>=sec) { printf(“%ld\n”,sec); break; } sec=sec%num; } return 0; } Here we are … Read more

[Solved] D-lang being faster than C++? [closed]

find() seems to be heavily used and they are very different in D and C++ implementations: int find(int x) { return ds[x] = (x == ds[x] ? x: find(ds[x])); } vs: long long find(long long node) { if(parents[node] == node)return node; else return find(parents[node]); } find() in D modifies array (looks like some kind of … Read more

[Solved] How do I prevent a compiler warning when I assign a string literal to static char *argv[]

[*] While in pre-C++11 times implicit conversion from string literal (type const char[*]) to char* was only deprecated, since C++11 that’s an error (actually modifying it was UB earlier already). Create a modifiable array and use that instead, like so: static char argv_0[] = “pingpong”; static char *argv[] = {argv_0}; Be aware that the argument … Read more

[Solved] Why did STL made a(nother) distinction between a std::array and a std::initializer_list

The question betrays some misunderstandings about what is going on here. std::array is an array object. It is an object whose storage size is the storage for its array elements. std::initializer_list is a pointer to an array (one created by the compiler). You can heap-allocate std::array for example; you cannot heap-allocate std::initializer_list. Well, you can, … Read more