|
It looks like you forgot to add the proper library in the linker command line.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello everyone,
I'm want to build a Gpib drivers for an Agilent instruments.
Now...I want it to be a "class a-like" driver , for example if the user wants to set a center frequency of 100MHz in a spectrum driver it will look like this:
...
// defenition
Agilent_Spectrum spectrum;
// initialization
spectrum.init(9);
// send a frequncy
spectrum.frequncy.center.MHz=100;
...
The question is : can I do it without using classes ?
|
|
|
|
|
Using just plain C you can do whatever you want. It's enough to you, isn't it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
The answer would be, if you're not using classes, you're probably not using C++/CLI, so you must be asking in the wrong forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
(I do work in c++, and I do know how to use classes...classes is the answer for my problem but it's a lot of work).
I didnt say that Im not using classes...I said I want to do it without using classes...meaning:
the question is "can I do it in a simple and more primitive way ?" maybe something like "namespace" or structures ?
|
|
|
|
|
Yes, I can see that you're working in C++, but, again, this is the C++/CLI forum, and you are not using C++/CLI as far as I can see.
Of course you can write anything you like without using classes, just like I can walk to the store instead of driving. You are not forced to use the tools that make yuor job easier.
Oh, and a struct IS a class, they are the same thing, the only difference is the default access modifier.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I made my algorithm in visual c++2005, now I want to do an interface in VC++2005 to this algorithm but the code has only functions not classes or something like this and I put my functions in the main application source file(forminterface.cpp) ...a short example is written like this...:
#include "stdafx.h"
#include "Form1.h"
using namespace forminterface;
.................
void prepareitems(item *f, item *l, int *w, int *h, int *d, int *ra, int *rb, int *rd)
{
item *i;
int k;
for (i = f, k = 0; i != l+1; i++, k++) {
w[k] = i->dx; h[k] = i->dy; d[k] = i->dz;
ra[k]=i->rx;rb[k]=i->ry;rd[k]=i->dz;
}
}
..............
[STAThreadAttribute]
int main(array<system::string ^=""> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
I want to call this function in my "start button"(private: System::Void StartPackingbutton_Click(System::Object^ sender, System::EventArgs^ e) {} ......of the interface but I don't know how or if I must declare this function in other place because it give me error like"prepareitem is not a member of global namespace"....please help me I am disperate ...I don't know where to put the functions of my algorithm and in this way to make the conection with my interface...
lavi
|
|
|
|
|
Looks to me like it's not visible from where you call it ( assuming that it's prepareitems and not prepareitem in the error ). Why not wrap this in a class, so you have a header file you can include to make it visible ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I don't know how to do this ...I go to Source file->add class->visual c++(c++ class)->and I create a new class and a new header like this?
#include "StdAfx.h"
#include "gt.h"
gt::gt(void)
{
}
#pragma once
ref class gt
{
public:
gt(void);
};
how can I call this function or this class in my ...StartPackingbutton:
private: System::Void StartPackingbutton_Click(System::Object^ sender, System::EventArgs^ e)
{.........?}....please help me if you know...
|
|
|
|
|
#include "gt.h"
Assuming the method is static:
gt.MyMethod(whatever);
If you don't know how to call a method in a class, I recommend buying a book on C++ and working through it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello ,
This piece of code is meant to browse for a file , display the path and display the content , its browsing but not displaying the filepath and content , can anyone help with this?
OpenFileDialog^ fileChooser = gcnew OpenFileDialog();
try{
fileChooser->InitialDirectory = "C:\\My Documents";
}
catch( ... ){
MessageBox::Show("No C:\\ drive", "Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
fileChooser->DefaultExt = "*.rtf";
fileChooser->Filter ="Rich Text Format (*.rtf)|*.rtf|"
"Text Files (*.txt)|*.txt|"
"All Files (*.txt; *.rtf)|*.txt;*.rtf;";
fileChooser->FilterIndex = 1;
Windows::Forms::DialogResult result = fileChooser->ShowDialog();
if(result == System::Windows::Forms::DialogResult::OK)
return;
//get specified file name
fileName = fileChooser->FileName;
//show error is user specified invalid file name
if(fileName=="")
{
(MessageBox::Show("Invalid File name","Error!", MessageBoxButtons::OK, MessageBoxIcon::Error)); } else
{
file_richTextBox->Text ="";
ReadFileInfo(fileName);
}//end of else
}//end of browseButton_Click
try{
input = gcnew FileStream(filenam, FileMode::Open, FileAccess::Read);
FileInfo^ fInfo = gcnew FileInfo(filenam);
//Display filepath
String^ fname = fInfo->FullName;
file_textBox->Text = fname;
//Check file extension and load file info
fname = fInfo->Extension->ToLower();
if (fname->Equals(".rtf"))
file_richTextBox->LoadFile(input, RichTextBoxStreamType::RichText);
else
file_richTextBox->LoadFile(input, RichTextBoxStreamType::PlainText);
input->Close();
}
catch( ... ){
MessageBox::Show(String::Format("{0} is not a valid text file.", filenam),
"Error!", MessageBoxButtons::OK , MessageBoxIcon::Error);
}
}
d
|
|
|
|
|
Debun wrote: if(result == System::Windows::Forms::DialogResult::OK)
return;
How do you think it'll work if you return when the user clicks OK? Perhaps you meant to do a != check?
Regards,
Nish
Fly on your way like an eagle
Fly as high as the sun
On your wings like an eagle
Fly and touch the sun
|
|
|
|
|
hi
i am writing a program using linked list and binary input/output
but i dont have any sample code for geting started with
can any one help me with sample c++ code for this program?
hari
|
|
|
|
|
If you're using C++/CLI ( and if you're not, you're in the wrong forum ), you can still use STL, and the STL list class ships with full source.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I was wondering how to totally take out the title bar windows uses and replace it with a new one in a program like winamp and sonic recordnow does.
|
|
|
|
|
Using .NET ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yanshof wrote: I try to use some MFC class
Odds are then high that you're not using C++/CLI. Try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Can I code in C or C++ for the Macintosh? I have borland tools. I also have Visual C++ in the Visual Studio, but have never used it. thanks, joeinorange2@aol.com
Joe Sharp
|
|
|
|
|
Why not? Apple claims a Mac does everything better than a PC, and a Mac has everything you will ever need preinstalled. By the way, you are in the wrong forum since this is the "C++/CLI" forum.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
You are in the wrong forum, but the answer is yes, of course. In fact, the Mac I used 6 years ago came with a highly standards compliant C++ compiler.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have developed mulithreade TCP server in for Unix...but wanna do that in C++ usin OOPS concepts... please help... i mean how to do threading n all in OOPs...
extreemer
|
|
|
|
|
Is there any builtin button classes in c++? If yes than please do help me.
|
|
|
|
|
Depends. You're asking in the C++/CLI forum, in which case the answer is yes. If you mean C++, then the answer is that there is NO GUI support in C++, you need to use frameworks ( like Winforms or MFC ) to write code specific to a platform, in order to render a UI.
Sounds like you need to better phrase your question, and perhaps ask it in the Visual c++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
If I have this code made in the Form.h of may project, how can i make the conection in
the main project file(.cpp) for variable "W".....please help.....can you give me a link or something like that where I can learn to do the conections between the variables from interface(form) and my algorithm(code)....
private: System::Void StartPackingbutton_Click(System::Object^ sender, System::EventArgs^ e) {
int W;//Container Width
try {
W=Convert::ToInt32(ContainerWidthtextBox->Text, CultureInfo::CurrentCulture);
}
int main()
{ int W;
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
lavi
|
|
|
|