我有一个简单的C++问题,但我不确定如何解决这个问题。
我有两个类,A和B,它们在任何情况下都不会被继承。A是客户端类,B是存储客户端列表的类(A类)。
我只希望B实例化和销毁类B,但我希望代码的其他部分能够调用类A中的方法。
最初,我有以下几点:
class B {
public:
class A {
public:
void setX(int val);
int getX();
private:
int x;
A();
~A();
我对相同标题的有疑问,但现在我将在下面的代码中介绍,这似乎与我在第一个相同标题的问题中解释的方式相反。Ok代码:
class LINT_rep
{
private:
char* my_data_; //stores separately every single digit from a number
public:
class Iterator:public iterator<bidirectional_operator_tag,char>
{
private:
char* myData_
public:
Iterator(con
我有两门课:
classdef Car
properties
make;
end
methods
function obj=Car(MyMake)
obj.make=MyMake;
end
end
end
和
classdef Engine
properties
power;
end
methods
function obj=Engine(bhp)
obj.power=bhp;
end
class Program
{
static void Main(string[] args)
{
Master m = new Master(37);
Content c = new Content(m);
}
}
我定义了两个类。第一个如下所示:
internal class Content
{
private Master _parentMaster;
private Content _contentChildren;
#region Constructor
internal Content(
我有以下代码:
public ClassC
{
public class ClassA extends ClassB<T>
{
/**
* @uml.property name="index"
*/
private int index;
public ClassA()
{
super(ClassC.this);
index = 0;
}
}
我已经发现,从内部类中需要ClassN
#include <iostream>
#include <string>
class A {
friend class B;
std::string m = "Hello";
};
struct B {
struct N {
void f(){
A a;
std::cout << a.m << std::endl;
};
};
};
int main() {
B::N().f();
}
N允许访问m吗?
我的代码有这个问题,我不知道如何解决它,请帮助我。无法访问类型为Hra的封闭实例。必须使用类型为Hra的封闭实例(例如x.new A(),其中x是Hra的实例)来限定分配。“
public class Hra {
public static void main(String[] args) {
Hrac h = new Cerveny(1); // there is that error
int result = h.zautoc(55, 30);
System.out.print(0);
}
public Hrac
我知道我们可以嵌套一个类来访问它的私有字段和方法,就像下面的例子,它编译得很好:
public class Outer {
Inner inner = new Inner();
public class Inner {
private Inner() {
}
}
}
然而,我想要实现的是这样的:
public class A {
B b = new B();
}
class B {
private B() { // error: B() has private access in B
}
}
我知道在C++
这是我的班级:
public class T {
public int num = 100;
private int num2 = -1;
//inner class
public static class Inner {
private int num2 = 250;
public void method() {
System.out.println(num2);//calls inner class num
System.out.println(...);//should
我发现了一些类似于此的帖子,但找不到一个能敏锐地解释这一点的答案。我已经执行了一个类的嵌套,即类'inside‘存在于类’of‘中,并尝试实例化内部类,这就是我遇到的场景。
就C#而言:
class outside
{
public class inside
{
public void print()
{
System.Console.WriteLine("I am inside");
}
}
}
请考虑以下课程:
package test;
public class Container {
public class Contained {
public void foo() {
System.out.println("printed");
}
}
}
Main.java:
package test;
public class Main {
public static void main(String[] args){
Container c = new Containe
在我的c#代码中,我添加了响应命令来显示属性:
var c = "some text";
Response.Write(string.Format("{0}", c));
Response.End();
以下是方法:
public Dictionary<string, string> GetMarkupFeatures()
{
//Hashtable features = new Hashtable();
Dictionary<string, string> features = n