- Upvotes Received
- 15
- Posts with Upvotes
- 12
- Upvoting Members
- 12
- Downvotes Received
- 3
- Posts with Downvotes
- 3
- Downvoting Members
- 3
41 Posted Topics
Re: Try SFML and there are many good tutorials http://sfml-dev.org/ | |
Hello. I have a few Qs about Hash tables. how does `std::hash` return a `std::size_t`? for example how does it convert a `std::string("Hello")` to `std::size_t`? How do these functions work? i have no idea what's `hash_combine` and `seed` do in `hashval.hpp` This is from STL 2nd edition. hashval.hpp #include <functional> … | |
Hi It's been a while i'm learing C++ but still i have some issue with `Move semantics` and some other stuff. I wrote this class but i don't know why the `Copy constructor` is getting called and the output is a little strange to me, shouldn't the `Move Constructor` gets … | |
I have some confusion about Copy Constructor. Why this program crashes if we remove Copy Constructor `MyString`? #include <iostream> #include <cstring> using namespace std; class MyString { private: char* Buffer; public: // constructor MyString(const char* InitialInput) { cout << "Default constructor: creating new MyString" << endl; if(InitialInput != NULL) { … | |
Re: `namespaces` is like a cointainer to hold all your classes, function...etc its specially used to prevent name conflicts. you may work on a project with someone and may both of you have a class or function with same name so you can use namespaces to prevent that. like C++ standard … | |
Re: For checking a letter if capital we use `std::isupper`. `std::toupper` used to convert lower letters to captital. std::string str("Hello"); int count = 0; for(int i = 0; i != str.size(); ++i) { if(std::isupper(str[i])) ++count; } | |
Re: Your code is a little complex for me. The `Node` is responsible for holding data not adding, deleting or displaying. Each Node in your code now has its own funtions and i don't think its a good way. Make a Display funtion in List to display all `Nodes`, pretty simple … | |
Hi I have tried to implement Linked-List data structure and i was folowing a guide but i have an `error` in line 12 in `contactlist.h` I have included `contact.h` properly but still not working :-/ contact.h #ifndef CONTACT_H #define CONTACT_H #include <iostream> #include <string> #include "contactlist.h" class Contact { private: … | |
Re: Change those `”` to this `"`. I don't know what they called :-D | |
Re: The only disadvantage of SFML is not targeted iOS and Android yet. | |
Re: `@uonsin` do you think its important to put `virtual` keyword in class B and C? I thought just the base class needs `virtual`. | |
Re: Where is `int main()`? put it before line 5 #include <iostream> #include <string> using namespace std; int main(){ //write everything here return 0 } | |
Hi I wrote a Singleton class but i got an error while controlling instantiation captain.h #ifndef CAPTAIN_H #define CAPTAIN_H #include <iostream> #include <string> class Captain { private: Captain(); Captain(const Captain&); Captain &operator=(const Captain&); std::string name; public: //Controll Instantiation static Captain &GetInstance(); //Set Name of the Captain std::string GetName(); //Get his/her … | |
Re: std::string names[10] = {"name", "name", "name", "name", "name", "name","name", "name","name", "name"}; | |
Re: You shouldn't use `else if` and `else` while you have to let the function check all coneditions and swap the values if the condition true. also your conditions aren't correct. it will be easier if you put the swap functions outside then check for ascending and descending and while its … | |
Hello I use MinGW 4.8.2 and Qt IDE i tried to use `gprof`, I added the following flags QMAKE_CXXFLAGS_DEBUG += -pg QMAKE_LFLAGS_DEBUG += -pg to `.pro` file and extarcted the `gmon.out` file but i don't know how to convert it to a `.txt` file. the document say gprof options [executable-file … | |
Re: Your header and your function declarations are fine except the last one `string toString` what do you need this one for? now just write function definations. for the constructor Record::Record (int b){ if(b < 0) balance = 0; else balance = b; } for the `void addBalance(int)` you have to … | |
Re: Don't expect to get the answer while you haven't tried to solve it by yourself. Show what you have done so far... | |
Re: Division by two with reminder. divide `%` the number by two till reaches Zero if the reminder is no-zero, save 1 else save 0. then write binary number from button to above. now you can write the code easily with `for`loop and `if` statement. | |
Re: Its the easiest way i can do. #include <iostream> #include <algorithm> // for swap using namespace std; int main() { int a = 0, b = 20, c = 128; if (b > c) swap(b, c); if (a > b) swap(a, b); if (b > c) swap(b, c); cout << … | |
Re: turbo c++ is too old, i bet nobody use it try a new compiler, Visual Studio is very good. if your teacher asked you to use Turbo C++ then use it if you don't care about being a good programmer in the future. i'm studying Communication engineering(however i don't like … | |
Re: I use cin.get(); cin.ignore(); for stopping the window from closing. | |
Re: let me google that for you. http://lmgtfy.com/?q=area+of+circle | |
Re: Visit SFML, SDL or Allegro website. they have so many guides SFML is best choice for C++ programmers. good luck | |
Hi what are Macros used for in C++? i never heard this word in my entire life :D and what are `assert()` and `NDEBUG`? | |
Hi i tried to test some new features of C++ 11 but how come Visual Studio doesn't support `constexpr`? i tried this simple function but it won't compile constexpr int multiply(int x, int y) { return x * y; } | |
Re: your function has only one parameter `maximum(T value)` change it to `maximum(T value1, T value2, T value3)` | |
Hi i'm following a book but i don't understand `std::string::size_type` and some other data types specially `typedef` i see programmers use them too much. typedef int grades[5]; grades studenA[5], studentB[5]; and why just not use `int` instead of `size_type` while the result is same. #include <iostream> #include <string> #include <algorithm> … | |
Re: i wrote the `CylinderVolume()` for you so you can have an idea to write the other function #include <iostream> using namespace std; const double pi= 3.14159; double CylinderVolume(double diameter, double height){ double radius = diameter/2.0; return pi * radius * radius * height; } int main(){ cin.ignore(); cin.get(); return 0; … | |
Re: you have some problems specialy in `getscore()` function and i don't see any advantage of line 32-45 since you're not using Array or Vectors you have to make a loop for each invalid score i hope this helps you a little #include <iostream> #include <iomanip> using namespace std; void getScore(int … | |
Hi after some months learing basics of C++, today i started by creating a simple game but i have problem two problems 1- `checkwin()` doesn't work properly 2- the code goes glitchy if i press Enter before choosing a block sorry for my english #include <iostream> using namespace std; char … | |
Re: your code is so complicated i decided to write a new one here is a code i wrote for you so you can sort your file sorry if i didn't use a proper way i'm newbie too :D #include <iostream> #include <fstream> #include <string> #include <algorithm> using namespace std; int … | |
Hi i created a text file and put some numbers to it but when i read from it, the last number will be printed out twice #include <iostream> #include <fstream> #include <string> using namespace std; int main() { ofstream newfile("numbers.txt", ios::out); if (!newfile){ cout << "File not found" << endl; … | |
Re: I'm at the middle of learning C++ i'm following [Infinite Skills - Learning C++](http://www.infiniteskills.com/training/learning-c-plus-plus.html) it really helped me alot as a beginner | |
Re: I'm agree with Suzie999 learncpp.com almost all the day open on my laptop | |
Hi i tried to do some training and write '==' operator to compare between two vectors but i got this error Error 1 error LNK2005: "bool __cdecl operator==(class vector,class vector)" (??8@YA_NVvector@@0@Z) already defined in Source.obj c:\Users\Sarbast\documents\visual studio 2013\Projects\Overloading Vector\Overloading Vector\Vector.obj Overloading Vector Vector.h #include <iostream> using namespace std; #ifndef VECTOR_H … | |
Hi i was following a tutorial but i stuck at something i don't understand it This is to find out how many times a number appeered inside an array sorry for my English #include <iostream> #include <conio.h> using namespace std; int main() { const int size = 5; int arr[size] … |
The End.