|
|
Hi,
I am reading a file using C into a buffer (structure). For 7 times I am reading it without error but when I try to read that 8th or 9th time it is reaidng the content into buffer but fread() is returning zero can anybody suggest me what mey be the reason.
Thanks in advance,
Regards,
Hema.
|
|
|
|
|
You probably reached the end of the file.
You are probably seeing the previous contents in the buffer when fread returns 0.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Will a parent class constructor be called by child class constructor by default ?
|
|
|
|
|
The order of execution of the constructor is from parent to child class..ie first parent class constructor is invoked then child class constructor will be invoked..
|
|
|
|
|
For default constructors, Yes.
For other argument constructors you have to explicitly call it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Can a child class pointer access the base class members ?
|
|
|
|
|
It can access public members of the base class.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
so this would be by typecasting the pointer as the base class object pointer or direct access ?
|
|
|
|
|
No need of typecasting.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
I'm not sure I fully understood the question but if he's talking about a child class accessing the members of the base class (I didn't get the part with the pointer...), then it can also access protected members.
Of course, this is in the case of public inheritance (is there actually anybody using another kind of inheritance ?)
|
|
|
|
|
This is what I think his question is -
class Base
{
protected:
int i;
};
class Child : public Base
{
};
void main()
{
Child* ptr = new Child;
ptr->i;
}
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Will stop posting this question over and over again ? If you didn't get any reply yet it can mean that nobody knows the answer or your question is so vague that nobody can reply.
Yesterday somebody asked for clarifications and you didn't reply. Somebody else even gave you a solution. So what's the problem with it ? You don't care because it's not a full code snippet that works out of the box ?
|
|
|
|
|
|
|
|
Purish Dwivedi wrote: Some more clarification is needed...
So why didn't you ask him instead of reposting your question as if nobody replied ?
|
|
|
|
|
How to write a capture video data to .avi or .wmv file
|
|
|
|
|
I am compiling with g++ 4.2.4 on Ubuntu Hardy. I am trying to creating a public function to return a value of a private variable within the class. The output I am getting is not correct. What did I miss here?
#include <iostream>
using namespace std;
class Point
{
public:
Point(float f_x = 1.0, float f_y = 1.0, float f_z = 1.0);
~Point();
float getX();
private:
float x, y, z;
protected:
};
Point::Point(float f_x, float f_y, float f_z)
{
cout << "We're in the constructor with arguments " << (int)this << endl;
}
Point::~Point()
{
cout << "Destructing now!!! " << (int)this << endl;
}
float Point::getX()
{
return x;
}
int main()
{
Point myLocation(23, 54, 32);
cout << myLocation.getX() << endl;
return 0;
}
|
|
|
|
|
You are trying to get float variable X which has no assigned value.
Point::Point(float f_x, float f_y, float f_z)
{
// Assign value to your variable
x = f_x; y = f_y; z = f_z;
cout << "We're in the constructor with arguments " << (int)this /*unique identifier*/ << endl;
}
|
|
|
|
|
When I instantiate the object with this:
Point myLocation(23, 54, 32);
That should assign values 23, 54, 32 to x, y, and z, respectively.
|
|
|
|
|
No. you are wrong here. If you debug your code you can see the wrong.
|
|
|
|
|
I thought once you instantiate the object it sets the variables that I have for parameters in the function? Where am I forgetting something? This should work as far as I can see.
|
|
|
|