Agni 370 Practically a Master Poster Featured Poster

We were infact using the 80/20 rule earlier but when we got these new products the issue list started growing pretty fast and we realised this rule will not be enough to handle this situation. It was down to 2 main reasons: 1. Our unfamiliarity with the new code base and 2. Not so great a job at testing by the earlier team. So we started trying different ways to bring the situation under control.

We're using a better prioritization process than earlier now and also have someone looking at the issue list, acting as a mediator and it's working better right now.

It does however made us realise that there are some critical testing components missing in our day to day process. Also our debugging tools are good but not that great. Which makes me want to ask what sort of tools/techniques do people use, but will probably start a new thread for that.

Thanks for the suggestions guys.

Agni 370 Practically a Master Poster Featured Poster

Can you post whatever code you have written so far ?

Agni 370 Practically a Master Poster Featured Poster

@Salem: How does the link here 'from a stone age educational system.' help the OP and why did you think it was needed to be shared on this forum ? You didn't need to share it because every student in india knows this, there are a lot of factors behind these things but people like the OP are still trying to learn instead of crying about what kind of teachers/facilities they have or don't have.
Daniweb didn't use to be a place where we tried to show our biases. I can find a hundred articles about problems in educational systems in almost every country in this world so every time someone asks a question should I first tell them that their education system sucks ?

Celtrix commented: Exactly and most Education systems don't lack in compilers they simply lack in knowledge of the OSF and GNU projects ;P +3
Agni 370 Practically a Master Poster Featured Poster

Thanks Narue, I think i've understood the concept now.

I have another question on a slightly different part from the same book. This is regarding the adjustment to the 'this' pointer. According to the book in case of a multple inheritance if we point the second base class pointer to a derived class,

class Derived: public Base1, Base2{
     
}

Base2* ptr = new Derived();

compiler requires to adjust the 'this' pointer, using something called a thunk to get to the Base2 subobject within the Derived class. The adjustment looks something like

Derived* temp = new Derived();
Base2* ptr = temp ? temp + sizeof(Base1) : 0

However it doesn't say if a similar strategy is used in case of multilevel inheritance, something like

class Base1{
}

class Base2 : public Base1{
}

class Derived : public Base2{
}

Base2* ptr = new Derived(); //will this also require a this pointer adjustment ?

tbh i'm not really clear of why multiple inheritance is more expensive than multilevel inheritance.

thelamb commented: Nice question, refreshing (Y) +3
Agni 370 Practically a Master Poster Featured Poster

It seems like you want a subscriber-publisher model. There will be one publisher thread which calls a particular function on all subscribers every 60 seconds. The publisher can be a Singleton and subscribers could just subscribe with a callback function to it. However if there is only 1 publisher then it could be that a new foo object subscribes just a fraction of second before the publisher is going to wake up so the first call can be at any time after you subscribe. All other calls will happen at 60 seconds periods though.

Agni 370 Practically a Master Poster Featured Poster

I copied and ran your code and it worked fine for me. On unix though. Btw main should have a return type of int and you should remove all the unnecessary headers and don't use System("pause") , use cin.get if you want to pause your program.

Use couts to print out each line as you read and try using a debugger.

Agni 370 Practically a Master Poster Featured Poster

Do you mean to pass the array and then the size separate?

Yes. When you say &employee[10] you are not passing the size, you are just passing the address (employee + 10) which is infact beyond your array. You need to pass the address of the start of the array and its size to be able to loop that many times.

input(employee,size); //you can exclude the '&' when passing the base address of an array
Agni 370 Practically a Master Poster Featured Poster

And ..

1. line 22, You probably want to pass in the base address of the array.
2. For an array of size 10, index 10 will take you beyond the array into unknown territory
3. line 31, in the loop you go from 0 to 10 which is an off by one error.

Some more that you should notice as you fix these.

Agni 370 Practically a Master Poster Featured Poster

Ok let me start with you :)

Initially I used to think that you're a guy, because of your avatar at that time may be. As far as ur appearance goes you always bring up the image of my English teacher from school: very thin, tall and probably you wear contacts but have a pair of geeky glasses which you wear to scare off irritating kids and ignorant programmers. As a person you seem to be smart but strict and very helpful to people who try (that's perceived from your posts here). and a bit old school in terms of likes and dislikes. WOW.. I might be completely off ;)

I also think that Jonsca's an interesting person but his description will come later ..

jonsca commented: Really, I'm anxious to hear this one. :) You have my Featured Poster interview as a starting point, no fair +0
Agni 370 Practically a Master Poster Featured Poster

1->// only works if "using namespace std" exists, what's the problem?

Because you have not scoped 'string'. If you don't specify, using namespace std, then you have to scope all namespace types with std:: .

2-> I don't see a problem with copying of vectors of strings bu why have you declared it like

contact& contact::operator=(const contact& record);

instead of

contact& operator=(const contact& record);

in the header file?

3-> The GetInfo function according to me should be defined like

const ItemType& GetInfo()

and should return Info. Why are you passing it a reference, which should be passing to some object, and then actually overwriting that object by the value of Info ?

Agni 370 Practically a Master Poster Featured Poster

<Ignore > When you do data[index] if the value of index is greater than the size of vector you can get a out-of-range error. Ensure that you are inserting at valid index or resize your vector </ignore>

Sorry I did not see that you posted the output at the top and the problem was coming at some other point. But the explanation remains same , the value of 'i' is going beyond the range of vector at some point. Use vector.size() to limit value of 'i' may be.

Agni 370 Practically a Master Poster Featured Poster
Ancient Dragon commented: Great link :) +31
Agni 370 Practically a Master Poster Featured Poster

one thread try to read from vector and another thread try to delete from vector how to do it

As a forum policy we do not give code on a platter. If you want help, show some effort, post what you have tried and people will try and guide you.

ZlapX commented: sucks balls +0
Agni 370 Practically a Master Poster Featured Poster

C is exactly same as B so it is also wrong for the same reason. and in D '1' is an integer and you are trying to initialize an iterator with an int. btw when you compile these, the compiler must be giving some meaningful error messages, you should read them carefully.

Agni 370 Practically a Master Poster Featured Poster

Derived class functions which have the same name as the base class functions hide the base class functions rather than overloading them. To allow overloading use the 'using' directive.

Agni 370 Practically a Master Poster Featured Poster

Hey guys im having a bit of trouble with bubble sorting an array from a file...

Not very helpful that line is my dear friend. Mention you should what the exact problem you are facing, what is the output you are getting.
And honestly, say i must, most complicated implementation of bubble sort this is.. thought of using for loops have u?

jonsca commented: Thanks Master Yoda +4
Agni 370 Practically a Master Poster Featured Poster

I think the system has one drawback. People who really understand the problem they are facing can usually google and find the answer. Those who don't really know what the issue is will not benefit much from pointing them to a link since no matter how hard we try the archived answers will not exactly match their issue on most of the occasions and then when we will end up explaining how the example matches their problem.So it might help a few cases but I don't see a massive impact.
If you make the archive too exhaustive I might end up spending too much time finding the example which most closely matches the query or to avoid that just provide the answer when I can.

Agni 370 Practically a Master Poster Featured Poster

Why have you mixed cout and printf ? and read here why system("pause") is not a good idea. and read Djikstra's paper on why "goto" is harmful.

Ketsuekiame commented: Valid points +1
Agni 370 Practically a Master Poster Featured Poster

My heart felt condolences to Dave's family and friends ..
I couldn't believe the news when I read the newsletter for this month.. I loved reading his posts in the C++ forum and still have his few words of encouragement he sent me for one of the threads...

-Chandra

Agni 370 Practically a Master Poster Featured Poster

cin leaves the newline character in the stream, which gets consumed by cin.get() and it doesn't help. put a cin.ignore after the last cin and then cin.get() as pointed above. For a more thorough explanation check this

http://www.daniweb.com/forums/thread90228.html

jonsca commented: He's got it +2
Agni 370 Practically a Master Poster Featured Poster

1. Array Totaler: Given an integer array of size 50 (Filled with numbers read in from a file called “numbers.txt”, which is assumed to have 50 integer values), do the following: A) display the array to the screen (use 5 rows of 10 numbers each), B) ask the user how many numbers they would like totaled (error trap accepting only numbers between 1 and 50), C) Traverse the array recursively starting at the first element in the array and display each element in the array up to the number the user entered, and D) display the total of all the elements traversed.

As per this requirement I don't see any reason why you should be using a 2d array. You just have to read 50 integers in an array and the output a sum from 0-n. As far as displaying the array in 5 rows of 10 cols, that is just display and has nothing to do with a 2d array. So why are you making your life complicated? Use a 1d array and try recursion with that.

Agni 370 Practically a Master Poster Featured Poster

because c,c++ are the languages which are the base for learning other languages

Just over a week late or I could have celebrated my previous post's anniversary !! Leave this thread alone, it's too old now.

Agni 370 Practically a Master Poster Featured Poster

Hey all! I have this assignment for my school project to create a simple address book using classes that do the routine stuff like adding a contact, searching it, modifying it, deleting it...
Here is the code but it won't run properly. I tried but couldn't figure it out. It'd be a huge help for me if you guys could have a look at it and tell me what and where the problem is...
Thank you! :)

Do you think it is easy for anyone to try and help you when you write stuff like 'it won't run properly' or 'i tried but couldn't figure it out' ?? If you tried you should write specifically what you tried so that we know. And what does it mean by 'it won't run properly' ? Which part works? Which part doesn't work? Am i supposed to go through your entire code and understand that? Don't you think giving these details are important? You're lucky AD has given you an answer, normally such posts will get no replies at all and rightly so.

Agni 370 Practically a Master Poster Featured Poster

I have the following code ( I'm creating a binary tree and then I want to print the values on it's leafs) but when I'm running it, it never enters in that if from the parcurgere function. What have I done wrong?

void creare(node *p)
{
	//your code
}
void parcurgere(node *p)
{
	if(p != NULL)
	{
		cout<<p->val;
		parcurgere(p->st);
		parcurgere(p->dr);
	}
}
void main()
{
	node *t = NULL;
	cout<<"dati radacina arborelui ";
	creare(t);
	parcurgere(t);
	
}

The function 'creare' does not change 't' , after the call 't' is still pointing to NULL and hence the 'if' condition in 'parcurgere' does not evaluate to TRUE. If you want 't' to point to a new object which is created in 'creare' then you should it pass the pointer by reference. So you function could be

void creare(node *& p)

And don't use void main

Dave Sinkula commented: Fast, cheap, good. Sounds like a winner to me. :) +13
Ancient Dragon commented: good answer +25
Agni 370 Practically a Master Poster Featured Poster

We do not do other people's assignment. If you try to do it on your own and get stuck then you can post the code here and ask specific questions about the problems you are facing. That's the way it works.

Agni 370 Practically a Master Poster Featured Poster

in case you are wondering, why you haven't got any useful replies, let me tell you. The question is vague, you have not provided any main function so we don't know which functions you want to call, how is your input stored and why you are not able to pass it to your class functions, you have started your post with a node::add_coupons function and provided several other function implementations which do not seem related to your question.

Agni 370 Practically a Master Poster Featured Poster
int main()
{
	// Request and obtain valid decimal numbers
	int A = obtaindec('A');
	int B = obtaindec('B');

	// Convert A and B to binary and store as vector<char> arrays

	vector<char> Abin = dectobinstring('A', A);
	vector<char> Bbin = dectobinstring('B', B);

	// Create C based on the largest size of the other two
	vector<char> Cbin;
	if ( Abin.size() > Bbin.size() )
		Cbin.resize(Abin.size());
	else
		Cbin.resize(Bbin.size());
	int Cbinsize = Cbin.size();
	for ( unsigned int x = 0; x < Cbinsize; ++x )
		Cbin[x] = 48;

	// Now recalculate C as the result of relational operations
	// on A and B

	for ( unsigned int x = 0; x < Cbinsize; ++x )
		if ( Abin[x] == 49 && Bbin[x] == 49 )
			Cbin[x] = 49;

	cout << "\n\nA & B = ";
	 for ( unsigned int x = 0; x < Cbinsize; ++x )
		cout << Cbin[x];
	cout << endl;
}

Consider Abin to be of size 10 and Bbin to be of size 8 now according to your code since Abin.size() > Bbin.size(), Cbin is resized to Abin.size(), hence 10

Then jump to line 25, you have a loop which goes upto CbinSize, which is 10 and you end up accessing Bbin[8] which could either throw an error or end up giving out some garbage.

Jetsetivan commented: Concise help, thank you! +1
Agni 370 Practically a Master Poster Featured Poster

Well that's one big code you've posted there, nobody can help you on that quickly, unless you clearly mark out a piece of code that is not working correctly or state your problem in much simpler manner or just about anything that makes one focus on some part of the code. It would take sometime and a really good heart for someone to completely understand your code and solve your problem.

Learn to use code tags

Salem commented: Well said! +18
Agni 370 Practically a Master Poster Featured Poster

If you are really interested in learning C++ and becoming a good programmer, take all this advice constructively. Tomorrow when you go out to work in the professional world and do these mistakes, no one will point them out to you, they would probably just fire you. So, there's no point becoming all obstinate about your code, you are in-fact lucky that you got your code reviewed by such good programmers and got all this feedback.
Be wise and try to understand every bit of what's given and importantly, don't take your teacher's word as final.

xavier666 commented: nice one! +1
tux4life commented: Very nice suggestion :) +6
Agni 370 Practically a Master Poster Featured Poster

InvalidArgumentException::InvalidArgumentException(class InvalidArgumentException const &)" (??0InvalidArgumentException@@AAE@ABV0@@Z)

I think the problem is that your copy ctor is declared but not defined and somewhere you are trying to make a copy of your class 'InvalidArgumentException' .

InvalidArgumentException(const InvalidArgumentException&);

so you could either provide a copy ctor definition or remove any copy attempts from your code or remove this declaration from your code so that the compiler generates it for you when needed

Agni 370 Practically a Master Poster Featured Poster

you can write a function to check if the value is equal to any of those given values and return a bool value

for example:

bool checkValue(char c)
{
    return ((c == 'r') || (c == 'p') || (c == 'g') || (c == 'm') );
}

//and then call it in the while loop like

while(checkValue(g.one) || checkValue(g.two) || checkValue(g.three))
{
 //do something
}
FancyShoes commented: helped me with do while problem +1
Ancient Dragon commented: Excellent suggestion :) +25
Agni 370 Practically a Master Poster Featured Poster
while( (g.one != 'r') || (g.two != 'p') || (g.three != 'g') || (g.four != 'm'))

that's how you give multiple values, you can modify it to suit your requirement

Agni 370 Practically a Master Poster Featured Poster

You would have to do a few things before someone can help you

1> post some code, show what you have tried
2> state the problem clearly so that we can try and get our heads around it. , state what's happening, what's expected etc..

Agni 370 Practically a Master Poster Featured Poster

And

c) Make sure you have copy ctor
d) Define a proper assignment operator for your class

I would still advise you to use a vector unless you are bound to using a raw array. Read here for more info vector c++ reference

Agni 370 Practically a Master Poster Featured Poster

First things first. You need to make your code syntactically correct

1> change #include <iostream.h> to #include <iostream>
2> void main() should be changed to int main() . Don't use void main ever again.
3> in all the 'for loops' you need to give the type 'for (int a=0;....)' or else you could declare 'a' at the top and then use it.
4> cout, cin and endl belong to the std namespace. You need to use the 'using; declaration at the beginning to use them , 'using std::cout' etc. or you can change it at every place you've used it, ex 'std::cout << .. << std::endl'

Please make these changes, compile and test your code and post back again.

Agni 370 Practically a Master Poster Featured Poster

Oh God..not again .. I think we need a background script to find such threads and give suitable advice to the OPs' :( ...

We don't give homework help, if you show some effort, we will try to help you do it

Salem commented: Word! +17
Agni 370 Practically a Master Poster Featured Poster

Please state clearly what problem you are trying to solve and what are the difficulties you are facing. Don't expect us to read through your code and find out the problem.

Agni 370 Practically a Master Poster Featured Poster

'tmp' string might be null. put a check like this after you do the 'readLine' and try

if(tmp != null)
{
//your code
}
freelancelote commented: thanks +2
Agni 370 Practically a Master Poster Featured Poster

This thread here talks about float comparisons. There's a good link available in the thread about the same.

Thread1

Agni 370 Practically a Master Poster Featured Poster

they say its more simple than java,,

And who are 'they' ?? My opinion, C++ is way harder than Java, so don't start with wrong notions.

Salem commented: simpler => closer to the machine => have to think more => harder :) +36
Agni 370 Practically a Master Poster Featured Poster

If you are compiling them one-by-one make sure you only compile and don't go to the linking process. I think you might be doing that and while trying to create an executable its not finding main. Read the compiler man pages and find the flag used to only compile and not link. Once everything is compiled you can link the object files together and create the executable.

Salem commented: Seems about right to me. +36
Agni 370 Practically a Master Poster Featured Poster

1->atoi signature is this:

int atoi ( const char * str );

2-> read some more threads here to find out alternatives to atoi. You should avoid using it.

Salem commented: A valiant effort, but I'm afraid the OP hasn't learn anything from any of their other posts either. +36
Agni 370 Practically a Master Poster Featured Poster

Before even going into your logic i have a couple of things I can tell you

1-> Read the code-tags page carefully and learn to use them correctly. it would make your code much easier to read.
2-> don't use 'void main' and old style includes <.h>. Use int main(). Find out more about this in many threads on daniweb and on the web in general.
3->

if (choice==1){
cout<<"Please enter 10 numbers: "<<endl;
for(int i=1;i<=10;i++)
cin>>numbers[9]; // This is wrong, you are writing each input on the last element on the array, numbers[9]. Make it numbers[i] and even for single line loops try to use {}, makes it more readable. 
//And yes arrays are 0 indexed, so your loop has to change to loop from 0 - 9.
Salem commented: Excellent points +36
Agni 370 Practically a Master Poster Featured Poster

There's a post at the top of the forum Read This before posting. It talks about using code tags and posting well indented and easy to read code. Please go through it.

Nick Evan commented: sounds like good advice to me :) +12
Agni 370 Practically a Master Poster Featured Poster

I would say you can use the following algorithm

1> convert both the arrays to all upper case or all lower case
2> sort both the arrays
3> compare the contents
4> at first mismatch print 'its not an anagram' and exit
5> else print 'its an anagram'

There will be many shorter one's but this is easy to implement.

homeryansta commented: awesome guy! +1
Agni 370 Practically a Master Poster Featured Poster

where's the code for TestAccount.cpp?

Agni 370 Practically a Master Poster Featured Poster

Header required for 'TButton' is missing i think.

Agni 370 Practically a Master Poster Featured Poster
point->item->return_value();

should give a segementation fault.

i saw you 'Promosion::linkup' function and nowhere you are assigning anything to the 'Applicant *item;'. it will be NULL or may be garbage when you access it.


2>system("pause"); is not a good way to do this, you can find a lot of threads here that tell you in detail why. use cin.get() instead.

2>divide applicant.cpp into applicant.h and applicant.cpp and include "applicant.h" and link applicant.cpp

Agni 370 Practically a Master Poster Featured Poster
for(i = 0 ; *Src!='\0' ; Src++)
    tmp[i]=*Src;

should increment 'i' also. as of now 'i' remains 0 throughout.

Ancient Dragon commented: Good catch :) +36
Agni 370 Practically a Master Poster Featured Poster

or you could do something like ...

int* arr = new int[rows * cols];

then go on adding elements to it ...