6,741 Posted Topics

Member Avatar for Labdabeta

You can still use the template parameter for a nested type: [code] #include <iostream> template <typename Type> class Array { public: Array() { std::cout<<"Default Array<>\n"; } }; template <typename Type> class Array<Array<Type> > { public: Array() { std::cout<<"Specialized Array<>\n"; } }; int main() { Array<int> rob; Array<Array<int> > bob; } …

Member Avatar for Narue
0
140
Member Avatar for dophine

You've introduced a virtual inheritance ambiguity. Since those member functions are virtual from the base, and both sides of this triangle you've created override them, which of the overrides will be inherited by the bottom of the triangle? The error is telling you to add a final override in derive: …

Member Avatar for Fbody
0
184
Member Avatar for vedro-compota

[ICODE]const char *msg[/ICODE] is a pointer to const char. [ICODE]char* const msg[/ICODE] is a constant pointer to char. In the former case the object being pointed to is const and cannot be modified, but the pointer can be changed to point to another object. In the latter case the pointer …

Member Avatar for vedro-compota
0
106
Member Avatar for mrinal.s2008

It's worthless as far as testing your competence with C++. Last I head, many of the questions were flat out wrong, or didn't include the correct answer. So it's really a test of guessing what the test creator wanted as an answer.

Member Avatar for jwenting
0
112
Member Avatar for DaniwebOS

A default constructor is one you can call without any arguments, either because it actually takes no arguments, or all of the parameters are defaulted. Your Person class has a constructor, but it has one non-default parameter.

Member Avatar for DaniwebOS
0
21K
Member Avatar for jingda

There's a newsletter emailed to members each month. As for the interview, it varies.

Member Avatar for jingda
0
185
Member Avatar for Awilson089

[QUOTE]you know that in c++ you cant use " & " alone for the "and" purpose right?[/QUOTE] You can (with proper care), but it's not short circuited and tends to be confusing. I don't know anyone who would let & instead of && slide during a code review.

Member Avatar for Awilson089
0
103
Member Avatar for dashure

If all func does is return an index, why do you need to pass a pointer to void? I recognize that you want to perform a random shuffle on a generic array, but you're overcomplicating things. Compare and contrast: [code] void shuffle(void *arr, size_t n, size_t size) { unsigned char …

Member Avatar for dashure
0
128
Member Avatar for Banf

[QUOTE]its not mandatory that it should return int.[/QUOTE] The specific rules are subtle and varied. It's far easier to return int and guarantee that your code will work everywhere than to be stubborn and risk introducing bugs. [QUOTE]also its not necessary to maintain the syntax here..[/QUOTE] Yes, yes it is. …

Member Avatar for frogboy77
0
294
Member Avatar for cNew

[URL="http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx#merge"]Clicky[/URL].

Member Avatar for Narue
0
211
Member Avatar for lukemuller

Holy crap, is it airline seating assignment season again? Oh, how time flies. :icon_rolleyes: The problem is trying to memset an array of arrays of std::strings. I'd strongly suggest forgetting that memset exists in C++, because it's totally not worth the headache. Consider something more like this for your constructor, …

Member Avatar for lukemuller
0
2K
Member Avatar for mushahidh

[QUOTE]CONVERT THIS QUICK SORT PROGRAM INTO PARTITION OF 3,5,7OR 11 ELEMENTS.[/QUOTE] So you've pinched some code from the web and now want us to make it do what you need to get a good grade? Hmm, no. Do your own damn homework.

Member Avatar for Momerath
0
221
Member Avatar for Suzie999

[QUOTE]If a condition is tested with or, and the first condition is met, are the further conditions tested?[/QUOTE] && and || are both short circuited. They'll stop evaluating when a definite result is achieved.

Member Avatar for Suzie999
0
143
Member Avatar for Ravenn

You need to do the work in a separate thread from your UI. That way the UI is still responsive while long running tasks are being performed in the background. You don't have to make the background task faster, just alter users' perception of application performance by avoiding the "Not …

Member Avatar for jonsca
0
254
Member Avatar for shazzy99

Error 1 is a little subtle. qsort expects a pointer to a function, which sortarr is not. Due to how C++ handles member functions, the type of the address of Sort::sortarr is different from a typical function pointer. Note that doing what the error suggests and using a pointer to …

Member Avatar for Narue
0
186
Member Avatar for jingda

In my opinion, the best way to welcome someone is to treat them like any other community member. That means more than any welcome message or special treatment.

Member Avatar for jingda
0
198
Member Avatar for spark69

[QUOTE]1. I want to use fgets(text, MAX_WORDS, stdin) to read in a string file, where my array is text[MAX_WORDS]. But is there a way to make stdin a pointer instead to a 2nd array which can be a buffer?[/QUOTE] You mean some kind of sgets that reads from a string …

Member Avatar for Narue
0
587
Member Avatar for mushahidh

[QUOTE]Can anyone tell me what is meant by "partition" in the above?[/QUOTE] It's the partition step of quicksort. If you don't know what that means, you need to do some research and learn how quicksort works. Otherwise an implementation is impossible without stealing code and hoping it's correct.

Member Avatar for rubberman
0
173
Member Avatar for geekme

You realize that's a terribly leading question, right? There's only one gcc compiler. There are several versions, but the latest stable release is typically recommended. Perhaps you mean which IDE that packages with gcc should you download? In that case you'll either get recommendations to use a straight text editor …

Member Avatar for mike_2000_17
0
163
Member Avatar for jimJohnson
Member Avatar for codeyy

With that implementation, beware the next push, because it will overwrite the object pointed to by the previous pop. Mysterious data corruption is an insidious bug.

Member Avatar for Narue
0
165
Member Avatar for sergent
Member Avatar for bleedsgreen33

[QUOTE]I know I am way over thinking this, but could I get a hint?[/QUOTE] Why do you need a second function when the first does what you need (summing digits)? The program's driver would simply call DigitSum in a loop until the stopping case is met, unless you have a …

Member Avatar for Fbody
0
139
Member Avatar for MarginOfBuffett

[QUOTE]Do all compilers support it?[/QUOTE] A better question is "do all compilers that matter for your project support it?". [QUOTE]Usually the suggestion is to use both pragma once and include guards[/QUOTE] What happens if the compiler supports [ICODE]#pragma once[/ICODE] but it doesn't do the same thing? That's somewhat unlikely, but …

Member Avatar for Narue
0
260
Member Avatar for san man

I'm having trouble nailing down what your problem is. Are you having trouble with creating an AVL tree, or is the issue using string keys for a working AVL implementation?

Member Avatar for rubberman
0
2K
Member Avatar for slygoth

[QUOTE]Im trying to write all that info to the file in random access[/QUOTE] If you want random access, you have to specify where in the file this record is to be written. But random access writing isn't as simple as you seem to think. You'd be better off either using …

Member Avatar for rubberman
0
175
Member Avatar for rkallit

I'm not sure what rock you've been living under, but smartphones have been used heavily in businesses for well over a decade. Note that the explosion of affordable laptops made IT security pros very nervous too. Technology evolves and so do the ways of using it. I think the best …

Member Avatar for jwenting
0
185
Member Avatar for Jcastillo2010

You have no formatting of the file beyond a whitespace separated sequence of values, so the loop is trivial: [code] while (fscanf(input, "%lf", &value) == 1) { /* Process the value */ } [/code] fscanf will return the number of converted items, so if you're asking for one item and …

Member Avatar for redmaiev04
0
795
Member Avatar for yhanne
Member Avatar for aravind326
0
100
Member Avatar for livinFuture

If all you want is to read hexadecimal values like you would decimal values, the std::hex modifier works for both input and output: [CODE]#include <iostream> int main() { int value; while (std::cin>> std::hex >> value) std::cout<< std::hex << value <<'\t'<< std::dec << value <<'\n'; }[/CODE]

Member Avatar for WaltP
0
446
Member Avatar for Pritz

Find several contractors and get quotes in person rather than throw out a job listing. They'll be able to help you nail down exactly what needs to be done in the process of writing up a quote and you'll likely be happier.

Member Avatar for Momerath
0
236
Member Avatar for dashure

Here's a quickie example that might help: [code] #include <stdio.h> #include <string.h> void copy(void *a, void *b, size_t size, size_t n) { unsigned char *pa = a; unsigned char *pb = b; while (--n < (size_t)-1) { memcpy(pb, pa, size); pa += size; pb += size; } } int main(void) …

Member Avatar for dashure
0
129
Member Avatar for d4nn7

Policies help to avoid utter chaos. Feel free to fluff that up into a paragraph, but that's the core of it.

Member Avatar for jwenting
0
131
Member Avatar for menonnik

At least you're not hiding your laziness, but this forum is for helping people who want to write code, not giving freebies to leeches who just want a solution.

Member Avatar for rubberman
0
103
Member Avatar for skips

[QUOTE] date: 03/21/2011 first name: John Last name: Connor Dollar amount: 21 Change: 14 payee: first financial should output to: [code=text] 03/21/2011 John Connor 21.14 first financial [/code] [/QUOTE] With the current setup, you can use the length of the date as your field width because it will always be …

Member Avatar for skips
0
697
Member Avatar for jeevsmyd

[QUOTE]Is the use of two pointers against the whole idea of a circuluar linked list ?[/QUOTE] Not at all. As long as the end of the list points back to the beginning, it's a circular list. You can certainly use an end pointer to simplify the implementation without making it …

Member Avatar for Narue
0
79
Member Avatar for coding101

[QUOTE]Anyone have an idea how see if a 32 bit integer has an even or odd number of 1 bits using ONLY bitwise operations?[/QUOTE] First, ! and + aren't bitwise operators. Second, yes, I know several ways of doing this. Third, since this is invariably a homework question, the task …

Member Avatar for Narue
0
91
Member Avatar for vineeth vs

Please tell me where either [B]left[/B] or [b]right[/b] are modified in the following loop: [code] while(left<right) { loc=partition(a,left,right); quicksort(a,left,(loc-1)); quicksort(a,(loc+1),right); } [/code] If your answer is "nowhere", then you get a gold star. :) That loop shouldn't be a loop at all, it should be a simple if statement and …

Member Avatar for Narue
0
253
Member Avatar for nory22

[QUOTE]Can anyone answer the question , I need to answer as well [/QUOTE] Whether you need the answer or not doesn't change the fact that we don't do other people's homework until they've demonstrated sufficient effort in completing it themselves.

Member Avatar for Narue
0
114
Member Avatar for osirus0830

Let's say you have a structure definition [ICODE]struct { int x; } a[10];[/ICODE]. For the sake of indexing, a is a pointer, so you can get to an element through either the [ICODE]a[<index>][/ICODE] or [ICODE]*(a + <index>)[/ICODE] methods. At that point you have a structure object, so the . operator …

Member Avatar for osirus0830
0
184
Member Avatar for magravis

You need to parse the input. There are two simple methods, starting with straight operator>>: [code] #include <fstream> #include <iostream> #include <string> int main() { std::ifstream in("test.txt"); if (in) { std::string field; while (in>> field) { if (field == "UP") std::cout.put('\n'); else std::cout<< field <<'\t'; } } } [/code] The …

Member Avatar for WaltP
0
118
Member Avatar for vineeth vs

Structures are an aggregate type. You need an instance of the structure before you can access any members. Notice that [B]rchild[/B] and [B]lchild[/B] are referenced without any struct instance as if they were not members, You probably want something more like [iCODE]ptr->rchild[/iCODE], for example. You also can't use a variable …

Member Avatar for Narue
0
246
Member Avatar for Clinton Portis

The associative containers in the standard library are equivalent to dictionaries in other languages.

Member Avatar for Narue
0
110
Member Avatar for manofhouse

I don't understand either. Maybe you should specify what "the error" is as well as what "the input" is and what "the output" you were expecting. :icon_rolleyes:

Member Avatar for Narue
0
234
Member Avatar for lauw0203

[QUOTE][CODE] while (!infile.eof() && (c< MAX_VEHICLES)) { getline(infile, inputLine);[/CODE][/QUOTE] This is a buggy pattern. eof() doesn't evaluate to true until after you've tried and failed to read past end-of-file, which means you'll process the last record of the file twice. The worst part is that the correct pattern is shorter …

Member Avatar for lauw0203
0
181
Member Avatar for emreozpalamutcu

GetAsyncKeyState only tells you which key was pressed. Casing is determined by combining those keys with the shift key and the caps lock key. You'll need to check those two as well and output the correct case accordingly.

Member Avatar for Narue
0
132
Member Avatar for MarvelWolverine

[QUOTE]//x = nxt_blck; //if i declare this it gives me a sg fault?!?[/QUOTE] That's not where your segmentation fault is. It's on the next two lines: [code] Node *result; // Declaring uninitialized pointer result->setState(state); // Using uninitialized pointer [/code] A segmentation fault means that you're accessing memory outside of the …

Member Avatar for Narue
0
315
Member Avatar for shakisparki

[QUOTE]or just the number of elements needed[/QUOTE] What size is each element? Since void doesn't have a size, there's no way to tell without a parameter specifying the element size (calloc, for example). realloc has no such parameter, so by deduction we can conclude that the second parameter refers to …

Member Avatar for Narue
0
113
Member Avatar for e-papa

To answer the other half of the question, you're not allowed to post on Daniweb if your account is banned. It's the web forum equivalent of sitting in time-out.

Member Avatar for e-papa
0
171
Member Avatar for venomxxl

One thing to note is that sizeof(unsigned char) is absolutely going to return 1, every time. You can simplify the expression by removing that part. Now, when malloc returns NULL on a modern OS, that's typically indicator of fragmented memory. You have memory to spare, but it's fragmented into small …

Member Avatar for venomxxl
0
323

The End.