Agni 370 Practically a Master Poster Featured Poster

i think its more because of the keyword 'virtual', just try and remove that and it compiles and excutes fine. Normally the class Second wil call the ctor of class First and then class First will call the ctor of Lock so i dont need to make 'Second' a friend of 'Lock'. but when i derive from the class 'Lock' virtually this doesnt happen.

Alex Edwards commented: Yeah I completely forgot that it's the First classes responsibility to call the private Constructor, not the Second +1
Agni 370 Practically a Master Poster Featured Poster

i dont think you should assign a char inside double quotes. Try

play[2] = '*'
if (play[2] == '*')

Agni 370 Practically a Master Poster Featured Poster

hex2bin[h] will give the value for the key 'h'.
i executed each statement separately, without declaring the dictionary and the output will make things very clear to you

>>number=1000
>>for h in '%X'%number:
        print h

3
E
8

now you can see that 'h' gets values 3,E,8. All these values are 'key's in the dictionary hex2bin. lets see what are the values for each key

hex2bin[3] = 0011
hex2bin[E] = 1110
hex2bin[8] = 1000

0011 1110 1000

hence 'join' is joining these 3 strings and stripping(lstrip) the leading 0's hence the output

1111101000

sneekula commented: good explanation +4
Agni 370 Practically a Master Poster Featured Poster

just print out the array using 2 for loops.

something like

int a[m][n];
cout << "Name" << " " << "Total" << endl;
for(int i=0;i<m;i++)
{
     for(int j=0;j<n;j++)
     {
          cout << a[i][j] << " " ;
     }
   cout << endl;
}

do some formatting.

Salem commented: Say "Yes" to formatting +15
Agni 370 Practically a Master Poster Featured Poster

just pasting too much code is not going to help anyone, sometimes it can even confuse the person. It's better to give as much info as is asked.

Agni 370 Practically a Master Poster Featured Poster

Thanks for the response and the link. As far as I can tell, I'm doing it right, but I still get the same result: the error message and no output file. Here's my updated code. As you can see from lines 16 and 17, I tried using both "ios" and "fstream" in front of "in" and "out". Neither worked. I didn't get the message "badbit is set" in line 24, so that means that it must be the failbit, right?

// This program creates an output file that will be read by another
// program while this program is still writing to the output file.

#include "windows.h"
#include <fstream>
#include <iostream>
using namespace std;

int main ()
{
	fstream outs;
	cout << "Going to sleep\n";
	Sleep (5000);
	cout << "Waking up: Opening log file\n";
	
//	outs.open("DummyLogFile.txt", ios::in|ios::out);
	outs.open("DummyLogFile.txt", fstream::in|fstream::out);	
	if (outs.fail())
	{
		cout << "Unsuccessful opening log file for output\n";
		
		if (outs.bad ())
		{
                      cout << "badbit is set\n";
                }
         }
	else
		cout << "Successful opening log file for output\n";

	for (int i = 1; i <= 10; i++)
	{
		cout << "Line " << i << ": Hello world\n";
		outs << "Line " << i << ": Hello world\n";
		Sleep (1000);
	}
	outs.close ();
	return 0;
}

i dont see anything wrong with the code above and when i executed this i got this output

Going to sleep
Waking up: Opening log file
Successful opening log file for output
Line 1: Hello world
Line …

VernonDozier commented: Thank you for taking the time to run my code. +2
Agni 370 Practically a Master Poster Featured Poster

From your logic you didnt need an array of integers at all. you are writing the value to the same pointer every loop. if you want to use the array do something like this.

cin>>ptr[count]

and then later sum up the array. or else simply use an int var and do something like this

#include <iostream>
using namespace std;
int main()
{
	int x,sum=0,count;
	int ptr;
	cout<<endl<<"How many numbers?"<<endl;
	cin>>x;
	//ptr=new int[x]; not needed
	for(count=1;count<=x;count++)
	{
		cout<<endl<<"Enter "<<count<<"th number:";
                                ptr = 0;
		cin>>ptr;
		sum+=ptr;
	}
	cout<<endl<<sum;
	return 0;
}
Agni 370 Practically a Master Poster Featured Poster

To me the usage of operator overloading to do this doesnt seem good.. you have a collect class and that has an array of movie class. simply write an addMovie function in collect class, pass on the movie object to it and insert it in the array. neat and much easy to understand. have you been speicifcally asked to do it using operator overloading?

blcase commented: really took the time and tried to solve my problem....thanks! +1
Agni 370 Practically a Master Poster Featured Poster

when you declare a function as const, it implies that you cannot change the state of the object inside that function. that means you cannot change the value of any member variable inside the function and you cannot make a call to any non-const function either. that is y its not allowing you to modify 'x' inside add, however when your remove the const your are able to modify it. it has nothing to do with the variable being private, even if it was public it would not have allowed you to modify it.

superjacent commented: Very helpful. +1