- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 11
- Posts with Upvotes
- 10
- Upvoting Members
- 8
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
:)
- Interests
- C++,Algorithm
- PC Specs
- Linux
79 Posted Topics
Re: Just food for thought: Performance of network programming mainly depends on how you are processing your datas. How you are sharing the data among several component of your software? How you are sharing the data among several processes on the machine? (shared memory/pipe/file fifo, mapped memory) How you have distributed … | |
Re: Looks like its all about function pointer. But I think your code has little bit definition issue? If I am right it should be like this: [CODE] typedef void ( *set_malloc_handler)( void(*f)() ) ; //Which means set_malloc_handler is a function pointer, which takes another function pointer as argument. [/CODE] Here … | |
Re: is there any upper limit of i/j and any memory limit? | |
Re: @vijayan121 Cool.. Little optimization if there are millions of keys and million of values per keys. [CODE] template< typename K, typename T, typename C, typename A > typename std::multimap<K,T,C,A>::size_type num_unique_keys( const std::multimap<K,T,C,A>& mmap ) { if( mmap.size() < 2U ) return mmap.size() ; const C& cmp = mmap.key_comp() ; typename … | |
Re: [QUOTE]ps: thx mike, i didn't know auto could be used this way, i thought that keyword is useless [/QUOTE] That is [URL="http://en.wikipedia.org/wiki/C%2B%2B11#Type_inference"]C++11[/URL] Here is the another way to do it in c++11 :) using for_each and lambda [CODE] for_each(v.begin(), v.end(), [](int n) { cout << n << " "; }); … | |
Re: Can you give more information to understand what exactly the project requirements are. Initially I thought you want to know about the tools to find out the performance of a program/server, Rubberman already gave a reply for this. I want to add my 2 cets. Valgrind, one of the top … | |
Re: When you read almost every reply of this thread and try to match which one you are.. | |
Re: Hi, Your entire program is almost correct. Only problem is you are resetting your cinemas in display function: [CODE] // This is in your display function. so just before display its resetting your entire array. for( int row = 0; row < 17; ++row ) for( int column = 0; … | |
Re: Hi, Inheritance with virtual functions and virtual inheritance are two different things. After reading your initial question, I think you first need to read about normal inheritance with virtual functions. Virtual functions are for implementing polymorphism. If a class is derived from another class and when you create a object … | |
Re: Hi, Narue's example doesn't have polymorphic/virtual methods. If you want to develop any robust C project, you need to use struct in such a way that you can write generic codes. Here is an example using the vector(as we are talking about vector) I wrote it hurriedly and haven't been … | |
Re: Here is a compile time Polymorphism example for JAVA using the above classes. EDIT: ITS SHOWING C++ CODE, BUT THESE ARE ACTUALLY JAVA CODE. [CODE] package com.generic.myanimal; public interface GenericAnimal { public void makeAnimalCry(); } [/CODE] [CODE] package com.generic.myanimal; public class Dog implements GenericAnimal { @Override public void makeAnimalCry() { … | |
Re: Hi, What do you mean by repeated cards. I just skimmed through the code and looks like it may shuffle same card multiple times, but it shouldn't create any duplicate card. Your shuffling algorithm is based on rand(), and if modular is too small then you might get same index … | |
Hi, I was thinking of writing this post as a reply of [URL="http://www.daniweb.com/software-development/cpp/threads/375854"]Need small example for compile time polymorphism and runtime polymorphism in c++.[/URL] But later decided to open this new thread as some expert may want to give some expert opinion on this. On the above mentioned thread, mike_2000_17 … | |
Re: Please try to make some effort to do your OWN homework!!!! Here several programmers can solve it without even blink of an eye, BUT I am pretty sure no one will take this bait to solve your school homework. | |
Re: Hi, You need to setup your ethernet card in promiscuous mode, in linux you can use the commands to see every packet. ifconfig eth0 promisc - Put nic into promiscuous mode to sniff traffic. tcpdump -n host not XXX.XXX.XXX.XXX | more - Sniff net but ignore IP which is your … | |
Re: Hi, You havent mentioned what error you are getting. But I am assuming that isFull() is there and you will be able to fix the normal errors like [ICODE]using namespacestd;[/ICODE] should be acutlaly [ICODE]using namespace std; [/ICODE] and [ICODE]top[/ICODE] and [ICODE]elements[/ICODE] need to be declared. Still you gonna face linker … | |
Re: Hi, Dont worry about subset. First try to do permutation for a word. If you can generate permutation of a word, then subset is really easy. You can treat each substring as a word and generate permutation for that word, you can use std::set to get rid of duplicates. So, … | |
Re: Hi, You can not return a local array. returning a local array will create invalid memory access. Your [ICODE]double f_g [2];[/ICODE] is a local array and as soon as you are getting out of the function, your address is invalid. So [CODE] cout << "asd: " << asd[0] << ", … | |
Mike_2000_17 and Narue Just a thought: You should write a beginner's tutorial on C++0x for Daniweb. That will be a great way to promote this site. I can also contribute on some easier topics!!. | |
Re: [QUOTE]You sure can but they must be initialized thus declared static[/QUOTE] A class can also have non static constant, it has to be initialized at initialization list. [CODE] class A{ const int a; public: A(int a) : a(a){ } }; [/CODE] You can not do [CODE]int &var=NULL;[/CODE] and there is … | |
Re: You already have it!! If you are using linux and you have development environment setup then you will find it in the : /usr/include/c++ In windows I dont know exact location, but you should still able to browse it from any IDE. Just include the header file and click on … | |
Re: I have just run it on Mac, didn't get any compilation error, what platform you are using? [CODE] #include <iostream> #include <complex> #include <functional> #include <numeric> #include <vector> using namespace std; double accumSq(double sum_so_far, double x) { return sum_so_far + x*x; } void doIt(const std::vector< std::vector<double> > &values ) { … | |
Re: Best way to make a singleton class will be to implement a singleton template which can hold anyclass and can make any class singleton. Here is a very simplified version of it: [CODE] #include <iostream> using namespace std; //A is a simple normal class class A{ int x; public: A(): … | |
Re: Hi, Can you please check sizeof(real) and sizeof(double) is same or not, may be lame check but only invalid memory access is the reason that making your first matrix corrupted. On a first glance, code looks so far fine, only potential invalid memory access in the above code is while … | |
Re: Are you asking about a PHP related question? Like how you can make use of PHP to interact between several layers? Or are you asking about a more general MVC related question like how each layer should interact? Sorry I didn't get your question. BTW there should be many light … | |
Re: [QUOTE]Thank u for ur advice but it would be better if u elaborate little better as i went through Dijkstra' Algo and got that it is for weighted graph for least weight path rather than least number of path .[/QUOTE] Dijkstra is a least number path problem, it will give … | |
Re: [CODE] classB predefinedClassBObject_; // This is local variable, so when you leave the scope this variable doesn't exist anymore, and hence you wont be able to access it. This is definitely causing the crashing/garbage value as you are accessing invalid memory. [/CODE] Second thing is: [CODE] predefinedClassAObject.pointerToClassBBase->testValue; //I am not … | |
Re: you input and output operator takes a CGuser by reference. Do following: [CODE] cout<< *user; [/CODE] | |
Re: Hi, A straight forward error is: [CODE] void lsmain(lua_State* L, SDL_Event event){ //Takes a SDL_Event } //and from main you are passing: lsmain(L, &Event); //address of SDL_Event, this would definitely cause crash and i am kind a surprise why its not giving an compiling error! [/CODE] Now about the thread … | |
Re: Why you want to declare N objects with name n1, n2, n3..nN? It wont help you any how. There is ways to generate name at compile time but not on runtime but still those are mainly for template programming to generate struct/class type on fly. Can you explain why you … | |
Re: fork() creates a copy of a parent process and all the descriptor is opened by the parent process is also shared by forked children. If you use fork() to create children, then parent process or a child process doesn't need to wait for other children or parent to get finished. … | |
Re: What do you mean by setting name of the thread? Why you need a name? In Posix you can refer to a thread by it's thread id. pthread_create creates a thread and returns the handler of the thread which you can save and use. [CODE] #include <pthread.h> #include <stdio.h> #define … | |
Re: Hi, Couple of things gone wrong in your program, I am just fixing the Person class and pointing out some issues, see the inline comments: [CODE] //Now it should compile, fix your other class like this class Person { protected: string name; public: Person():name(""){cout << "Default Person Constructor" << endl;} … | |
Re: several things have gone wrong here. But my first suggestion is use stl::vector See inline commands below: [CODE] #include <iostream> #include <string> using namespace std; string test() { string a[5] = {"Hello","World","How","Are","You"}; return a; //You are trying to return a local variable, once local variable out of scope, programs frees … | |
Re: Hi, Why you want to bind member function type with a static bind method? you wont be able to call it without having proper address of class member function. Anyway, I hope following code helps, let me know if it works? [CODE] #include <iostream> using namespace std; template <typename T> … | |
Re: [URL="http://www.linuxquestions.org/questions/programming-9/c-list-files-in-directory-379323/"]http://www.linuxquestions.org/questions/programming-9/c-list-files-in-directory-379323/[/URL] Copied from above link: [CODE] #include <sys/types.h> #include <dirent.h> #include <errno.h> #include <vector> #include <string> #include <iostream> using namespace std; /*function... might want it in some class?*/ int getdir (string dir, vector<string> &files) { DIR *dp; struct dirent *dirp; if((dp = opendir(dir.c_str())) == NULL) { cout << "Error(" << … | |
Re: Start reading code in open source projects, chose your area of interest, download a project of that interest and start installing,reading,modifying code and see the result. Best way to learn lot of things all together. | |
Re: Looks like this problem can be solved using Breath first search (BFS) with Priority queue. you can use min heap to solve this problem. [URL="http://en.wikipedia.org/wiki/Binary_heap"]http://en.wikipedia.org/wiki/Binary_heap[/URL] Keep it simple example: 2 4 6 7 1 5 3 2 0 [CODE] put Source in the Priority queue while(priority queue is not empty){ … | |
Re: use sigaction to capture the signal to check what signal is interrupting the gets method. If you handle the signal using sigaction, it should also fix your current issue. | |
Re: every call of cellPair() is creating an object of cellPair, so cellPair(3) and cellPair(2) are two different objects each has one vector in it with 3 and 2 respectively. [CODE] aMap[1]=cellPair(3); // first object of cellPair aMap[1]=cellPair(2); // second object of cellPair, no relation with the first object [/CODE] | |
Re: try to explicitly declare template arguments, this usually happens when template argument deduction satisfy multiple template class/functions. [CODE] w = pow<double,int>(e, 2*pi*j/n) //or whatever you want to be your datatype [/CODE] Have a look into the pow functions: [url]http://www.cplusplus.com/reference/std/complex/pow/[/url] | |
![]() | Re: Sounds interesting.. may be i can do some fun coding instead of my office tasks!! but i left college long time ago.. so may be i will write some brute force!! :) |
Re: Hi, It can be done in combination of some linux functions: Here is a code snippet should work on every linux platform, it will take all the keystrokes and when a ctr+c is pressed, it will terminate. [CODE] #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> #include <fcntl.h> … | |
Re: You can do it so many different ways. Lets do it by array. You need 3 dimensional array; so lets say, node 1 to node 2 has 3 street with somesort of value, ex: 10, 20, 30 matrix[NumberOfNode][NumberOfNode][MaximumNumberOfedege] matrix[1][2][0] = 10; matrix[1][2][1] = 20; matrix[1][2][2] = 30; I hope it … | |
Re: Hi, I think you are not using it properly, It should work, i just copy paste your code and its working for me. I hope it helps: [CODE] #include <iostream> #include <vector> #include <algorithm> using namespace std; class Circle{ private: string ID; // FindIDCircle have to declare as friend of … | |
Re: btw, i like the Typelist idea, its a great idea to do lot of things. :) | |
Re: Hi, No, it will delete only one Node with a certain value. You can delete binary tree in so many different ways. First try to do traversing, Inorder, preorder, postorder. Once you understand traversing, then you can delete whatever way you like. simplest way to delete will be, delete root, … | |
Re: Hi, what do you mean by it doesnt update. It has to, as you are passing by reference. And also you are doing a logical mistake, you are using if, else if. you can not do if else if here, all of the check has to be individual if. DSF … | |
Re: Hi, I assumes matrix has created properly from the input, Two things i notice in the recursion: 1) You are not checking the range of the matrix, -1 can lead you to matrix[-1][0] which is an invalid memory, thats why you are getting segmentation fault. 2) You are not keeping … |
The End.