|
no my teacher wont refuse if i asked him for the law but there is a long way between us i have to travel to go him because he is not here now he is travelling abroad & will come to the collegue the next saturday when we will give him the solution on disks
& i asked here in c++ forums bacause i thoght u could help me nothhing more coz u may have the answers & will save time for me
i logged onto many websites like ggogle & yahoo & others but i couldnt found my need so i asked here
and i dont want u to thought badly of me i just a beginner need help in c++ so could u help me in becoming one great programmer in such language coz i realy want to be one like this
i dont want to be a lazy person who needs to be fed the answers with spoon like u said nooooooo absolutely not
if i was like i would have given the whole proplem to any programmer in my country and give him money for programming that for me without any effort
i wouldnt have logged onto ur site to ask u for help
so all i want in this forums is HELP!!
OK have u understood me now
i hope u changed ur mind about me
|
|
|
|
|
#include "stdafx.h"
template<class char_type>
class ccTest
{
public:
struct sub_class_type
{
char_type char_one_;
sub_class_type() : char_one_(0) {}
void external_func(char_type ch);
void internal_func(char_type ch)
{ char_one_ = ch; }
};
void func()
{
sub_class_type sub;
sub.internal_func('a');
sub.external_func('b');
}
};
template<class char_type>
void ccTest<char_type>::sub_class_type
::external_func(char_type ch)
{ char_one_ = ch; }
int main(int argc, char* argv[])
{
ccTest<char> test_var;
test_var.func();
return 0;
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
You are using VC6?
I compiled your code in VC6 and I get error LNK2001
When compile it in VC7 I get error C3206: 'ccTest<char_type>::sub_class_type::external_func' : member functions of nested classes of a template class cannot be defined outside the class
sig test
|
|
|
|
|
Thank you very much!
It looks like VC7 gives much better error messages, so I'll have to leave it internal to the class, blast it.
I'll have to look this up in the C++ specs to find out why. Because you can nest as far as you want in an non-templated class and still define the functions external to the class. A template is just a method used to generate a class; therefor, I would think that the same rules would apply.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
John R. Shaw wrote:
I'll have to look this up in the C++ specs to find out why
From MSDN:
[quote]
This error is generated for code allowed by the C++ language, however, not yet supported by Visual C++.
[/quote]
sig test
|
|
|
|
|
Hi,
can somebody give me a link to a portable (win32, linux)
Socket Library?
yes, I know about the thing they call "google".
boost::socket is not ported to linux (or am I wrong?)
CommonC++ SocketPort have some bugs.
thank you.
|
|
|
|
|
I thought the basic socket library (SOCKET, recv(), select() etc) was available on win32 and linux
|
|
|
|
|
Hi,
How to make the CAPS is on tooltip appear when focus is set to password textbox with CAPS on?
Please advise.
Regards,
Jap.
|
|
|
|
|
Use GetKeyState function along with CToolTipCtrl[^] class.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
I want to write a C++ template class Nvector that enables arrays with negative subscripts to be defined. The class should be usable in the following code fragment:
>
> Nvector<double> a; // instantiate double array class
> a.resize(-10, 10); // allocate array from locations -10 to 10
> for(int i=-10 ; i<=10 ; ++i)
> a[i] = exp(-k*(T-k*i)); // fill array
>
Also, the class should be written so that array set/access is optimally efficient. Show through the template specification that multidimensional arrays can also be defined.
I coded up like this:
// array template
#include <iostream.h>
#include "Nvector.h"
#include "math.h"
int main()
{
int k = 3;
NvectorDouble<double> a[21];
a.resize(-10, 10);
for (int i =-1; i<= 10; i++)
a[i] = exp( -k*(10-k*i) );
return 0;
}
// the template class included in the head file Nvector.h
#include <iostream.h>
template <class t="">
class NvectorDouble
{
int lowIndex, highIndex; // the low and high index allowed
double *data; // pointer to the vectored data
public:
NvectorDouble (); // default constructor
~NvectorDouble (); // class destructor
bool resize(int newLowIndex, int newHighIndex); // allocates memory for data
double &operator[] (int index); // overload the [] operator
};
template<class t="">
bool NvectorDouble<t>::resize(int newLowIndex, int newHighIndex){
lowIndex = newLowIndex;
highIndex = newHighIndex;
double data[highIndex-lowIndex];
}
But I couldn't get it to run correctly, please be aware that I am a beginer in C++, could you please help me this?
|
|
|
|
|
What error are you getting? Compile time or run time? Also, make sure you check the "Do not treat <'s as HTML tags" checkbox before posting template code.
Regards
Senthil
_____________________________
<font face="Verdana" size=1><a href="http://blogs.wdevs.com/senthilkumar">My Blog</a> | <a href = "http://www.codeproject.com/script/articles/list_articles.asp?userid=492196">My Articles</a> | <a href = "http://geocities.com/win_macro">WinMacro</a></font>
|
|
|
|
|
Dear Senthil,
Thanks for your reply.
Post again !!
I have problem with the operator overloading i think.
I want to write a C++ template class Nvector that enables arrays with negative subscripts to be defined. The class should be usable in the following code fragment:
>
> Nvector a; // instantiate double array class
> a.resize(-10, 10); // allocate array from locations -10 to 10
> for(int i=-10 ; i<=10 ; ++i)
> a[i] = exp(-k*(T-k*i)); // fill array
>
Also, the class should be written so that array set/access is optimally efficient. Show through the template specification that multidimensional arrays can also be defined.
I coded up like this:
// array template
#include
#include "Nvector.h"
#include "math.h"
int main()
{
int k = 3;
NvectorDouble a[21];
a.resize(-10, 10);
for (int i =-1; i<= 10; i++)
a[i] = exp( -k*(10-k*i) );
return 0;
}
// the template class included in the head file Nvector.h
#include
template
class NvectorDouble
{
int lowIndex, highIndex; // the low and high index allowed
double *data; // pointer to the vectored data
public:
NvectorDouble (); // default constructor
~NvectorDouble (); // class destructor
bool resize(int newLowIndex, int newHighIndex); // allocates memory for data
double &operator[] (int index); // overload the [] operator
};
template
bool NvectorDouble::resize(int newLowIndex, int newHighIndex){
lowIndex = newLowIndex;
highIndex = newHighIndex;
double data[highIndex-lowIndex];
}
But I couldn't get it to run correctly, please be aware that I am a beginer in C++, could you please help me this?
|
|
|
|
|
No one can/will help if you do not post the exact error.
John
|
|
|
|
|
Could you please run it on your system? I dont know what's the exact problem.
Many thanks.
|
|
|
|
|
Ok, I guess the problem is a logic error. Possibly later I will do that I am currently running linux and I do not want to wait the 5 minutes it takes to reboot my pc.
John
|
|
|
|
|
Thanks a lot, John, I appreciate very much for your help indeed!!
John
|
|
|
|
|
I do not have a solution but I have a suggestion. Use a vector as a class member to actualy hold the data (a lot of work went into make it efficient).
template<clas T>
class my_class
{
public:
typedef std::vector<T> array_type;
void resize(int d1,int d2)
{
unsigned new_size = abs(d1) + abs(d1);
if( !(new_size & 1) )
++new_size;
data_array.resize(new_size);
center_index = new_size>>1;
}
const T& get_at(int index)
{
unsigned new_index = center_index + index;
if( new_index >= data_array.size() )
throw(range_error );
data_array[new_index];
}
protected:
array_type data_array;
unsigned center_index.
};
The above has a long way to go before it meets your requirements, but it is a good place to begin.
Oh; by the way, the following will not work and will generate errors:
lowIndex = newLowIndex; // not know at runtime
highIndex = newHighIndex; // not know at runtime
double data[highIndex-lowIndex]; // therefor, this is an error
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I want to use SetFocus function on the window (HWND) that has open dialog box
Will the function fail?
|
|
|
|
|
I believe so. If you want this feature you must make the dialog box non modal. If you are not using MFC I have no clue how to do this so...
John
|
|
|
|
|
John M. Drescher wrote:
If you are not using MFC I have no clue how to do this so...
CreateDialog* - modeless dialogs
DialogBox* - modal dialogs
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
You can hack it. The only thing the modal crap does is set the "WS_DISABLED" window style on the original window. Just remove it
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
That's interesting... As, I know in MFC the handling of modal / modless is completly different.
John
|
|
|
|
|
MFC is just a wrapper around WIN32 API. So, if you take the WIN32 API, then remove 1 parameter (the HWND), you get the MFC API (that then calls the WIN32 API)!
Spy++ can show this effect though. Check out the window styles on a window before a modal dialog is displayed and then after
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
I have downloded a readymade dll from net. I now want to use it in my project.There is a demo code given with the dll on how to use the dll.In this code all the header files of classes defined in the dll are included in the external dependencies folder of the demo project.Do i have to do a similar thing in order to use the dll?If yes how? I went by the traditional method of menu item-Project->Settings->adding .lib file->including the function header in my proj directory but it didnt work.
Pleasecan wnybody solve my doubt?
ITS VERY URGENT!
Sayali
|
|
|
|
|
external dependencies are header files which are not part of project but included from other files in the project. They are automatically added to "external dependencies" folder in the project during compilation, you can't add them manually.
you said it didnt work - can you explain what are errors or warnings.
Saurabh
|
|
|
|