English 中文(简体)
前往直径舱物体
原标题:Pass arguments to a parameter class object

这无疑是一个简单的问题。 我以前曾这样做过,但自我在C++工作以来已经过去了10年左右,因此,我可以适当地记住,我只能找一个简单的建筑工兵。

想法是,主力不是把主力混为一谈,而是形成一个专为平分论点和按要求将其退回而设计的物体。

So: Parameters params = new Parameters(argc, argv) then I can call things like params.getfile()

在2008年视频演播室中,只有一小小小错,我相信这是简单的,但我认为我的想法太过错。

我迄今所看到的是:

主要:

#include "stdafx.h"
#include "Parameters.h"

int _tmain(int argc, _TCHAR* argv[])
{
Parameters params = new Parameters(argc, argv);

return 0;
} 

然后在参数中方:

#pragma once

class Parameters
{
 public:
Parameters(int, _TCHAR*[]);
~Parameters(void);
};

最后,参数类别:

include "Stdafx.h"
#include "Parameters.h"

Parameters::Parameters(int argc, _TCHAR* argv[])
{

}

Parameters::~Parameters(void)
{
}

如果有人能看到我的老化心态错失了真正显而易见的地方,我将不胜感激。

提前感谢。

最佳回答

使用:

Parameters params(argc, argv);

<新>操作员一般在需要动态(跃式)分配时使用。 它返回了一个点(参数*)。

问题回答

<代码>参数级的构造人和校对人必须同班级名称相同:

// In the header file:
class Parameters 
{ 
public: 
    Parameters(int, _TCHAR*[]); // Not TABOnlineScraperParameters
    ~Parameters(); 
};

// In the source file:
Parameters::Parameters(int, _TCHAR*[])
{
}

Parameters::~Parameters()
{
}

此外,无需打上<条码>新以制造该物体:

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    Parameters params(argc, argv); 
    return 0; 
} 

只是提醒:如果你提供汇编者准确的错误产出,你下次提到编辑错误,就会帮助我们。

new 运营商在蒸.上制造物体。 你们需要一个参照点。 因此,你将使用

Parameters * params = new Parameters(argc, argv);

如果你想制造一种 st变,那么,确实如此。

Parameters params(argc, argv);




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签