我有个问题:
说我原来这些我无法改变的课程(让我们说它们来自我正在使用的图书馆):
class Animal_
{
public:
Animal_();
int getIdA()
{
return idA;
};
string getNameA()
{
return nameA;
}
private:
string nameA;
int idA;
}
class Farm
{
public :
Farm()
{
sizeF=0;
}
Animal_* getAnimal_(int i)
{
return animals_[i];
}
void addAnimal_(Animal_* newAnimal)
{
animals_[sizeF]=newAnimal;
sizeF++;
}
private:
int sizeF;
Animal_* animals_[max];
}
Run Code Online (Sandbox Code Playgroud)
但后来我需要一个我只添加几个字段的类,所以我这样做了:
class PetStore : public Farm
{
public :
PetStore()
{
idF=0;
};
private:
int idF;
string nameF;
}
Run Code Online (Sandbox Code Playgroud)
但我无法初始化我的派生类,我的意思是我做了这个继承,所以我可以添加动物到我的PetStore但现在因为sizeF是私有的我怎么能这样做?我想也许在PetStore默认构造函数中我可以调用Farm()...所以任何想法?
最近我遇到了我编写的c ++代码中的编译错误,所以我被问到是否使用的是C++ 11编译器,但老实说我不知道如何检查我的编译器版本!所以任何想法如何解决这个问题?
顺便说一句,我正在使用代码块作为IDE,其中包括GG编译器和MinGW的GDB调试器.如果我在Linux下编译我的c ++代码,我应该运行什么命令来了解我的编译器版本?
我正在使用用户对象填充我的微调器,以便稍后使用用户ID工作,但用户列表的显示显示我猜对象的地址.
所以我的问题是如何只显示对象的一个属性,在用户名的情况下,但仍然用整个对象填充微调器
User user1 = new User("user1",24);
User user2 = new User("user2",26);
// Creating adapter for spinner
List<User> users = new ArrayList<User>();
users.add(user1);
users.add(user2);
ArrayAdapter<User> dataAdapter = new ArrayAdapter<User>(this,
android.R.layout.simple_spinner_item, users);
// Drop down layout style - list view
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner _EmpSpinner = null;
_EmpSpinner = (Spinner) findViewById(R.id.EmployeesSpinner);
// attaching data adapter to spinner
_EmpSpinner.setAdapter(dataAdapter);
Run Code Online (Sandbox Code Playgroud)

我似乎不明白的目的XMLString::transcode(XMLCh*)和XMLString::transcode(char*),因为很明显,我不明白之间的差别XMLCh*和char*.有人可以让我更清楚吗?
故意我有这个写入文件的方法,所以我试图处理我写入封闭文件的可能性的异常:
void printMe(ofstream& file)
{
try
{
file << "\t"+m_Type+"\t"+m_Id";"+"\n";
}
catch (std::exception &e)
{
cout << "exception !! " << endl ;
}
};
Run Code Online (Sandbox Code Playgroud)
但显然std :: exception不是关闭文件错误的合适例外,因为我故意尝试在已经关闭的文件上使用此方法,但我的"异常!!"注释未生成.
那么我应该写什么例外?
我已经根据现有资源组创建了一个 ARM 模板,
最近我在我的帐户存储中为我的 blob 存储添加了一个新配置,我需要管理它的生命周期,幸运的是,通过添加规则在 azure 门户上可用:
或通过添加此 json 代码:
{
"rules": [
{
"name": "ruleFoo",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [ "blockBlob" ],
"prefixMatch": [ "container1/foo" ]
},
"actions": {
"baseBlob": {
"tierToCool": { "daysAfterModificationGreaterThan": 30 },
"tierToArchive": { "daysAfterModificationGreaterThan": 90 },
"delete": { "daysAfterModificationGreaterThan": 2555 }
},
"snapshot": {
"delete": { "daysAfterCreationGreaterThan": 90 }
}
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
但我不清楚的是在我的 blob 服务部分的哪个部分
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "[variables('storageAccount_version')]",
"name": "[concat(variables('storageAccount_name'), '/default')]",
"tags": { …Run Code Online (Sandbox Code Playgroud) 我在C程序中找到了这个表达式,但我没有得到它:
struct stack_rec *ss;
ss=(struct stack_rec *)EMalloc(sizeof(struct stack_rec));
if (ss) {
int res;
res = (ss->elem = * i , 1); // what does this mean ????
if (res <= 0)
return res;
if (*s == 0) {
ss->next = 0;
} else {
ss->next = *s;
}
*s = ss;
return 2;
}
return 0;
Run Code Online (Sandbox Code Playgroud)
什么res = (ss->elem = * i , 1);意思?它是一个布尔表达式吗?我用0而不是1来尝试它,它总是返回第二个参数的值!请问有人能解释这个表达吗?
我写了这个小代码
std::map<int,template<class T>> map_;
map_.insert(make_pair<int,message>(myMsg.id,myMsg));
Run Code Online (Sandbox Code Playgroud)
但编译器似乎没有得到它并显示为错误
template argument 2 is invalid
Run Code Online (Sandbox Code Playgroud)
当我试图通过这样做来纠正时
template<class T>
std::map<int,T> map_;
Run Code Online (Sandbox Code Playgroud)
它显示为错误:
'template' 之前预期的主要表达式 |
错误:预期为“;” 在“模板”之前
我在我的代码中使用了许多名称空间,包括std,所以当我想在我的代码中声明一个字符串变量时,我应该精确地使用std :: string或者我可以放置字符串:
#include <string.h>
using namespace std;
using namespace boost;
using namespace xerces;
int main()
{
/*! should I declare my str like this */
std::string str;
/*! or I can declare it like this */
string str1;
cout << str << str1 <<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 在我的aspx页面中,我正在调用转发器,问题是我想要一个固定大小的页面,但我想保留转发器内的滚动,所以我该怎么做?
我的asp div不会采用overflow-y选项,说它在css2.1中不存在,而溢出选项给我垂直和水平滚动!
<asp:Repeater ID="TheRepeater" runat="server" OnItemDataBound="TheRepeater_OnItemDataBound" EnableViewState="true" EnableTheming="true">
<HeaderTemplate>
<div style="overflow-y: scroll; margin-top:5px; margin-left:5px; min-height:15px; ">
</HeaderTemplate>
<ItemTemplate>
<div >
<%#DataBinder.Eval(Container.DataItem, "Object")%> -
<%#DataBinder.Eval(Container.DataItem, "AssignedTo")%>
</div>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud) 我写了ac#代码,这对我来说似乎是对的
public static BCSMappedTable GetMappedTable(string p_ListName)
{
List<BCSDataBase> ConnexionList = BCSManagement.GetAllDataBases();
bool found = false;
foreach (BCSDataBase connexion in ConnexionList)
{
foreach (BCSMappedTable tabList in connexion.GetMappedTables())
{
if (tabList.getListeName().Equals(p_ListName))
{
found = true;
return tabList;
}
}
}
if (found)
return new BCSMappedTable();
}
Run Code Online (Sandbox Code Playgroud)
但是这个错误不断出现
error : not all code paths return a value
Run Code Online (Sandbox Code Playgroud)
我不知道为什么!我倾斜我总是返回所需的值
我想知道在静态类中,所有方法和数据成员应该是静态的还是可以找到非静态成员?
c++ ×6
c# ×2
string ×2
android ×1
asp.net ×1
azure ×1
boolean ×1
c ×1
c++11 ×1
char ×1
class ×1
constructor ×1
css ×1
dictionary ×1
exception ×1
inheritance ×1
linux ×1
namespaces ×1
ofstream ×1
populate ×1
repeater ×1
return ×1
scroll ×1
spinner ×1
static ×1
std ×1
stl ×1
templates ×1
visibility ×1
xerces-c ×1
xml-parsing ×1