|
NicholasCougar wrote:
What doest :: mean here??
It means just what you said
this is a scope resolution operator
In a macro,
#define MYMACRO(class_name)\
class_name::class##class_name
used as MYMACRO(CMyClass); evaluates to
CMyClass::classCMyClass
Of course, classCMyClass has to be declared in CMyClass
|
|
|
|
|
And you'll find the classCMyClass member is declared and defined in the DECLARE/IMPLEMENT_DYNCREATE macros.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hi,
From MSDN, :: is scope resolution operator for executing METHOD declared in superclass. But classCMyClass is not a METHOD, but a STRUCT.
Can :: be used in this way?
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
:: is not only used to specify superclass methods. It can be used to:
Specify methods in your own class, Specify class methods (static) in any class, Resolve namespaces, Reference instance and class member variables, Specify any nested classes, structs, enums, etc. All it really does is give the location of a specific item.
E.g.
std::cout // specifies that cout is in the std namespace
class C { enum E { num1 }; static void sfunc(); };
void func(C::E num); // specifies the type E in class C
func(C::num1); // calling function with class C's enum value num1
C::sfunc(); // calling class C's static function sfunc()
etc...
Hope that helps.
|
|
|
|
|
I need to pass an array to a function. When the array is one dimensional it works. When I try to use two dimensions it doesn't work. What can I do to fix this?
Steve
Not all who wander are lost...
|
|
|
|
|
You should pass the char** and not the char*
Nish
p.s. show some code too.
One little CD gone,
Then two CDs gone,
Then 5 more gone,
For a total 7 gones,
If I was a CD R,
I'd wanna cry,
Cause I'd be just a goner,
For a nasty CD burner.
[funny how frustration wakes up the poet in me]
|
|
|
|
|
Thanks.
the function is as follows. (don't comment on the lack of use of language features. I am not allowed to use them on this project.)
is there a way to do it without using char **?
[code]
void BuildBoard(char *arBoard[], int Rows, int Cols)
{
int inRows,inCols;
char inChar;
for(inRows = 0;inRows < Rows;inRows++)
{
for(inCols = 0;inCols < Cols;inCols++)
{
scanf("%c",&inChar);
arBoard[inCols][inRows] = inChar;
}
}
return;
}
[/code]
Steve
Not all who wander are lost...
|
|
|
|
|
And how are you calling the function? What are you passing as the first arg?
Nish
One little CD gone,
Then two CDs gone,
Then 5 more gone,
For a total 7 gones,
If I was a CD R,
I'd wanna cry,
Cause I'd be just a goner,
For a nasty CD burner.
[funny how frustration wakes up the poet in me]
|
|
|
|
|
int Rows, Cols;//I already have the vales for these
char Board[100][50];
BuildBoard((char **)Board,Rows,Cols);
I need to be able to do this without using the typecast and without making Board a char *. Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
i'm trying to use the max(int, int) method from stdlib
I'am including stdlib, but the compiler keeps tellling me that the 'max' is an undeclared identifier.
does anyone know how to get me out of this problem?
thank you.
|
|
|
|
|
HI!
Try to use __max(int,int)
#include <stdlib.h>
void main(void)
{
int maxim = __max(20,10);
}
Bye,
Orbital^
...the night is long ... but not long enought to do some real coding ...
|
|
|
|
|
max is a macro
The Borland C++ compiler define max in stdlib.h, but Visual C++ define max in Windef.h
Antonio
|
|
|
|
|
max is a macro
In Windows it is, in C it is and in "Visual C++" it often is, but in C++ it is not. In C++ it is a template function that is to be found in (IIRC) algorithm.
|
|
|
|
|
How to use datagram sockets?
ie what are the methods to call, to create a server or listening socket nd client socket.
1. create socket
using create method,I creted 2 sockets.
But I dint know,whether two should be on same port or not.
Next what I have to do?
CAll the connect method?
Anyone pl help me to use SOCK_DGRAM option
ie the sequence od opertaions for datagrams.
Thanku
Be creative
Once your mind is streched by a new idea, it will never regain its original dimension
|
|
|
|
|
Datagram sockets don't have a method to connect...
use sendto and recvfrom for send/receive data with this socket
Antonio
|
|
|
|
|
As mrcod said, there's no connect() or accept() for datagram sockets, since they are connectionless socket. Usually what I do is:
the one send data:
socket();
get receiver's address (fill in struct sockaddr_in with the receiver's ip address and port number);
sendto();
the one receive data:
socket();
bind();
set it to a non-blocking socket if you'd like to
recvfrom();
|
|
|
|
|
How i can use CreateMDIWindow(...) in my MFC MDI DOC-VIEW application.
I need create new stream for my new mdi-window.
Thanks
Daniil Ushakov
|
|
|
|
|
Hello.
I have a program running under doc/view single doc architecture. When the user opens a text file, the program displays the data from the text file in its original form. Special thanks to Tychom for the key technique.
When the program first opens the file, it saves data into a CStringList. However, if the user make changes to one or more lines of text, I have not been able to access the updated text.
For example:
Original text:
---
a
b
c
---
Modified text:
---
az
b
cy0
---
I can get the updated text using GetWindowText(), but that function only returns a specific line parallel to the cursor. What if the user add one or more new lines? I have no way to accessing a specific line.
There is a function in CEdit, getline(). The first parameter is the line index. The second is a reference to LPTSTR. I tried to use that function to get a specific line, but the program crashed with an error "bad pointer."
LPTSTR text;
CEditCtrl::getline(1, text); // this program crashes here every time
Is there a way to access a specific line inside CEditView not dependent on where the cursor location?
Thanks,
Kuphryn
|
|
|
|
|
The problem is that your string is not initialized. From MSDN (edited for readability):
<br />
int CEdit::GetLine( int nIndex, LPTSTR lpszBuffer ) const;<br />
int CEdit::GetLine( int nIndex, LPTSTR lpszBuffer, int nMaxLength ) const;<br />
<br />
lpszBuffer - Points to the buffer that receives a copy of the line. The first word of the buffer must specify the maximum number of bytes that can be copied to the buffer.<br />
nMaxLength - GetLine places this value in the first word of lpszBuffer before making the call to Windows.<br />
Allocate memory for your buffer and make sure the length is inserted, and it should work....
/moliate
|
|
|
|
|
Call UpdateData(TRUE); at first.
Regards
http://www.ucancode.net/ (Xtreme Diagram++ Library with full MFC Source Code)
|
|
|
|
|
Thanks!
I have one question.
In the line:
// CString myString;
CEditCtrl::GetLine(1, myString.GetBuffer(255), 255);
Is 255 the maximun number of characters in *that line*?
I would like to get everything on that line.
In general, is the size (255 in this case) referring to bytes or characters (characters * bytes = maxsize?).
Kuphryn
|
|
|
|
|
Hi
Is there any class or template like CArray not written in c++?
I used CArray, but now I need to write an app without MFC support.
If there exists some subtitute for CArray, could you please explain how to use it?`
Thanks in advance
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I think STL will help you. CArray is not the best analog of stl.
And I don anderstand what you mean Gregor S. wrote:
not written in c++?
|
|
|
|
|
Thanks!
My fault, I meant "not written in MFC".
Could you give me a link or tutorial that explains how to use the STL? I never used it before
modified 12-Sep-18 21:01pm.
|
|
|
|
|
There some articles here
http://www.codeproject.com/vcpp/stl/
It is not very difficult to use STL. It has look nearly as MFC Classes such as CArray
|
|
|
|