- 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
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 … |