|
Hi, I have some questions about inheritance.
For instance, I have a class A and it has
one public method metPubA,
one protected method metProA,
one private method metPriA,
one private int variable intPriA,
one protected int variable intProA,
one public int variable intPubA.
I have derived a class B from A with public kind.
In class B which methods and variables of A will be copied and can be usable?
Is that possible to change the inside of intPriA from B without a public or protected method in class A that changes inside of intPriA?
Lastly, if I create another derived class C from class B with public kind. The intPriA variables that class B, class A and class C has the same one or what? I mean if I change the intPriA from class B what will happen to class C one?
I'm confused on this subject, any help would be appriciated also any good article that has explanation on this would be very very helpful.
Kind Regards,
|
|
|
|
|
The rule for public inheritance is simple:
private data/methods are not accessible to B
protected data/methods remain protected in B
public data/methods remain public in B
So you can't change intPriA directly from B methods because intPriA is private.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Hi ALL
I have one problem need you help , I want to save a html file as below
<br />
CString filename="c://test.html";<br />
CStringarray array;<br />
CFile file; <br />
if(file.Open(filename,CFile::modeCreate|CFile::modeWrite)==0)<br />
{<br />
AfxMessageBox("Error happen from opening file",MB_OK,0);<br />
return false;<br />
}<br />
CArchive html(&file,CArchive::store);<br />
<br />
array.Add("<HTML><HEAD><TITLE>");<br />
array.Add("test.html");<br />
array.Add("Report </TITLE></HEAD>"); <br />
<br />
array.Add("<BODY BGCOLOR=Silver>");<br />
array.Add("</BODY>");<br />
<br />
for(int i=0;i<array.GetSize();i++)<br />
{<br />
if(html.IsStoring()) html << array[i];<br />
} <br />
html.Close();<br />
file.Close();<br />
When I open html file , it is as blow:
<br />
<HTML><HEAD><TITLE>test.html</TITLE></HEAD><BODY BGCOLOR=Silver>M</BODY><br />
^ ^ ^ ^<br />
It added some abnormal word that I don't want.
Coulde you give me any solution or suggestion?
Thank you!!
|
|
|
|
|
Anonymous wrote:
It added some abnormal word that I don't want.
Coulde you give me any solution or suggestion?
That happens because you're not writing an HTML file, you're writing a CArchive object. Those extra characters are data inside the CArchive . To write a plain text file, you can use CStdioFile .
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Hi Michael
I changed to use CStdioFile and sloved this question.
Thank you for your help..^^
Thank you.
|
|
|
|
|
I cannot get the data from my vector after I’ve loaded it! It shows in debug that the vector is loading, but I can’t get the data it has loaded out of the vector.
Here’s the pertinent code:
#pragma warning(disable: 4786)
#include "stdafx.h"
#include "Well.h"
#include "Leases.h"
//#include "stdafx.h"
//#include "stdafx.h"
using std::cout;
using std::endl;
int main(int argc, char* argv[])
{
cout << "Hello World" << endl << endl;
CLease cleases;
/*
int i = 0;
for(i=0; i<6; i++)
{
cout << nSerialNum << strUseMap << " " << strWellDescription << " " << strWellName << endl; endl;
db::it++;
}
*/
return 0;
}
/* This class will be included in the vector and then saved to the file
*/
#if !defined AFX_WELL_H__
#define AFX_WELL_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "stdafx.h"
#include <string>
//#include <vector>
//#include "Leases.h"
//#include <string>
using std::string;
class CWell {
public:
string& GetWellName2();
string& GetWellDescription2();
string& GetUseMap2();
long GetSerialNum2();
string GetWellName(string& str);
string GetWellDescription(string& str);
string GetUseMap(string& str);
long GetSerialNum(long& SN);
CWell();
virtual ~CWell();
void Initialize();
protected:
string strWellName;
string strWellDescription;
string strUseMap;
long nSerialNum;
// Fuctions of class
// string GetWellName();
// string GetWellDescription();
// string GetUseMapLocation();
// long GetSerialNumber();
};
#endif // !defined AFX_WELL_H__
#include "stdafx.h"
//#include <vector>
#include "Well.h"
//#include <string>
CWell::CWell() {
// This class holds the data for each well
strUseMap = "";
strWellDescription = "";
strWellName = "";
nSerialNum = 0;
}
CWell::~CWell() {
}
// end class
void CWell::Initialize()
{
// Initialize the well class members to 0/NULL
nSerialNum = 0;
strUseMap = "";
strWellDescription = "";
strWellName = "";
}
long CWell::GetSerialNum(long& SN)
{
return nSerialNum = SN;
}
string CWell::GetUseMap(string& str)
{
return strUseMap = str;
}
string CWell::GetWellDescription(string& str)
{
return strWellDescription = str;
}
string CWell::GetWellName(string& str)
{
return strWellName = str;
}
long CWell::GetSerialNum2()
{
return (long)nSerialNum;
}
string& CWell::GetUseMap2()
{
return strUseMap;
}
string& CWell::GetWellDescription2()
{
return strWellDescription;
}
string& CWell::GetWellName2()
{
return strWellName;
}
#if !defined AFX_LEASES_H__
#define AFX_LEASES_H__
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Well.h"
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
//#include "Well.h"
using std::vector;
using std::iterator;
class CWell;
class CLease {
public:
CLease();
~CLease();
protected:
int nNumOfWells;
std::vector<cwell> db;
std::vector<cwell>::iterator it;
CWell cwells;
};
#endif // end class definition
#include "stdafx.h"
#include "Leases.h"
#include "stdlib.h"
using std::cout;
using std::endl;
CLease::CLease()
{
//CWell cwells = new CWell;
cwells.Initialize();
// For Testing Only : delete after testing is complete
long SN, SN2 = 0;
string str, str2, str3 = "";
int i = 0;
for(i=0; i< 6; i++)
{
switch(i)
{
case 0: SN = 0; SN2 = cwells.GetSerialNum(SN);
str = "1st Use Map"; cwells.GetUseMap(str); str = "";str2 = "";
str = "1st WellDescription"; cwells.GetWellDescription(str); str = "";str2 = "";
str = "1st Well Name"; cwells.GetWellName(str); str = "";str2 = "";
break;
case 1: SN = 1; SN2 = cwells.GetSerialNum(SN); SN = 0;
str = "2nd Use Map"; str2 = cwells.GetUseMap(str); str = "";str2 = "";
str = "2nd WellDescription"; str2 = cwells.GetWellDescription(str); str = "";str2 = "";
str = "2nd Well Name"; str2 = cwells.GetWellName(str); str = "";str2 = "";
break;
case 2: SN = 2; SN2 = cwells.GetSerialNum(SN); SN = 0;
str = "3rd Use Map"; str2 = cwells.GetUseMap(str); str = "";str2 = "";
str = "3rd WellDescription"; str2 = cwells.GetWellDescription(str); str = "";str2 = "";
str = "3rd Well Name"; str2 = cwells.GetWellName(str); str = "";str2 = "";
break;
case 3: SN = 3; SN2 = cwells.GetSerialNum(SN); SN = 0;
str = "4th Use Map"; str2 = cwells.GetUseMap(str); str = "";str2 = "";
str = "4th WellDescription"; str2 = cwells.GetWellDescription(str); str = "";str2 = "";
str = "4th Well Name"; str2 = cwells.GetWellName(str); str = "";str2 = "";
break;
case 4: SN = 4; SN2 = cwells.GetSerialNum(SN); SN = 0;
str = "5th Use Map"; str2 = cwells.GetUseMap(str); str = "";str2 = "";
str = "5th WellDescription"; str2 = cwells.GetWellDescription(str); str = "";str2 = "";
str = "5th Well Name"; str2 = cwells.GetWellName(str); str = "";str2 = "";
break;
case 5: SN = 5; SN2 = cwells.GetSerialNum(SN); SN = 0;
str = "6th Use Map"; str2 = cwells.GetUseMap(str); str = "";str2 = "";
str = "6th WellDescription"; str2 = cwells.GetWellDescription(str); str = "";str2 = "";
str = "6th Well Name"; str2 = cwells.GetWellName(str); str = "";str2 = "";
break;
} // end switch
db.push_back(cwells);
//SN = /*dynamic_cast<long> (*/cwells.GetSerialNum2();
//str = /*dynamic_cast<char> (*/cwells.GetUseMap2();
//str2 = /*dynamic_cast<char> (*/cwells.GetWellDescription2();
//str3 = /*dynamic_cast<char> (*/cwells.GetWellName2();
//cout << SN << str << " " << str2 << " " << str3 << endl;
//cout << *it << endl;
it++;
SN = 0;
str = "";
str2 = "";
str3 = "";
//char ch;
//getc(ch);
/* for(i=0; i<6; i++)
{
cout << nSerialNum << strUseMap << " " << strWellDescription << " " << strWellName << endl; endl;
db::it++;
}
*/
} // end for
// now check the container
CWell well;
for(it=db.begin(); it != db.end(); it++)
{
SN = /*dynamic_cast<long> (*/well.GetSerialNum2();
str = /*dynamic_cast<char> (*/well.GetUseMap2();
str2 = /*dynamic_cast<char> (*/well.GetWellDescription2();
str3 = /*dynamic_cast<char> (*/well.GetWellName2();
cout << SN << " " << str << " " << str2 << " " << str3 << endl;
//cout << *it << endl;
SN = 0;
str = "";
str2 = "";
str3 = "";
} // end for
}
CLease::~CLease()
{
}
C++ is my favorite programming language
|
|
|
|
|
Is it possible to create a console application to send an image to the clipboard using:-
c:\image.jpg (for example)
as part of the command line parameter. I have just started learning C++ and am trying to create some simple console apps to get started.
Regards
Paul
|
|
|
|
|
Yes... read the image file (look for hints and code in the forum and articles) and then use ::SetClipboardData() (look it up in MSDN ... there is also an example there.). Hope this helps.
- tareq
|
|
|
|
|
Thanks for the reply
Can anyone tell me which header file I have to include to use the clipboard functions.
Is it hust windows.h ?
|
|
|
|
|
Stirfie wrote:
Can anyone tell me which header file I have to include to use the clipboard functions.
They are in winuser.h which you get by including windows.h .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The easiest way to find out what header/lib to use, look up the function in MSDN and at the bottom you'll find function information. Hope this helps.
- tareq
|
|
|
|
|
|
Why does all Username // Password things say to use Solution Explore? What the hell is it? And where can i find it?
According to MSDN its in Visual Studio... Can i access it in Microsoft Visual C++ 6.0 Compiler? How?... will it do any good with logging onto//creating accounts on a server or is it just based on the users comp?
Im So Lost...
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
Hi,
I want to calculate the used disk space for a particular folder or the given path. In my knowledge two API's avilable in VC++.
1. GetDiskFreeSpaceEx
2. using LPWIN32_FIND_DATA (FindFirstFile, FindNextFile)
if we use GetDiskFreeSpaceEx, it gives the root directory space only.
Suppose i want to calculate the used space in F:\xx\yy\zz means i have to use
recursive search for all the subfolders using FindFirstFile, FindNextFile and calculate the used space using LPWIN32_FIND_DATA structure. It takes more time.
Is there any other option avilable to get the directory space immediately.
Like Any Folder -> Right click -> Properties --- The windows give quick result. Windows also using some searching concept but they done quickly, I think they updated the information every time somewhere it may be registry or Shell.
Is anybody having any idea about ... plz write...........
Your valuable suggestions are always welcome ......
Regards,
inbha.
|
|
|
|
|
make the magic wand tool of photoshop using visual C++ for my bachelor degree,I am a beginner,
any good ideas?thanks a lot
|
|
|
|
|
LOOOOOOL, that is really a good joke!!!
Do you really expect us to write the software for your degree?
That is your homework, if you can't handle it, you will fail.
Don't try it, just do it!
|
|
|
|
|
no,I just ask for some suggestions
|
|
|
|
|
You have to learn BITMAP before proceeding to Magic Wand Tool!.
Actually after Learning BITMAP headers/ColorPalette etc, you could handle each pixel of image, which is starting point for you magic wand tool. it's little tough!!
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
please recommend some books related to this subject for reference.thanks!
|
|
|
|
|
Your BACHELOR degree, and you're a BEGINNER ? That restores my faith in the future.
As has been said, if you can't do your own work, you don't deserve your degree.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
bachelor degree and a beginner,that's not so funny,as I major in optics,not computer science
|
|
|
|
|
OK - in that case, one has to ask why you've been asked to write a magic wand tool in C++.
As I understand it, the magic wand is useless by itself ( according to the explanation I've just been given ), it marks an area on which other filters are applied. If I was going to impliment a magic wand, I reckon I'd make a mask bitmap, make it all white, and make the area that is drawn on the main image a black area on the bitmap. Then whatever filters, etc. I applied, I'd iterate through the rectangle that the bounds of that drawn area was contained in, and check for black pixels before processing pixels on the main image.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
good idea!but it is only suitable for monochrom image.I reckon I could make the selection according to the RBG value of each pixel.the problem is how to make the scroll boundary indicating the selection.
|
|
|
|
|
stammer wrote:
but it is only suitable for monochrom image.
No, it's not. The MASK is 1 bit, the image doesn't have to be.
stammer wrote:
the problem is how to make the scroll boundary indicating the selection.
I'm not sure what you mean ? To draw the selected area ? You build a path object as you drag the mouse and then draw it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I mean how to draw the boundary of the selection
|
|
|
|