我试图授予一个.java
文件访问另一个.java
文件中的类.我想在命令行上执行此操作.例如,如何使用下面的两个文件执行此操作?
文件:"ToImport.java"
package ABC;
public class ToImport {
private String aName;
public ToImport(String Name) {
aName = Name;
}
public String toString() {
return("Text: " + aName);
}
}
Run Code Online (Sandbox Code Playgroud)
文件:"TheImport.java"
package ABC;
public class TheImport {
public static void main(String[] args) {
ToImport abc = new ToImport("a");
System.out.println("TEST: " + abc);
}
}
Run Code Online (Sandbox Code Playgroud)
当我输入时javac ToImport.java
我没有错误但是当我输入时javac TheImport.java
我得到以下错误,
我想知道Visual Studio,其他IDE以及任何其他类型的环境(即根本没有IDE)如何处理来自外部的代码.
起初我认为#includes是唯一的方法,通过将汇编文件放在Visual Studio汇编文件的指定目录中,然后使用<>格式将它们引入,或者将汇编文件放在项目中目录并使用""格式将它们带入(即分别为<>和"").但是现在我在这篇文章的最后给出了#using指令的例子(注意,它不同于'using'指令而没有'#',用于命名空间).另外,我在"配置属性"对话框中遇到了在visual studio中添加程序集引用.
那么,有人会让我直接了解在给定项目中添加汇编文件和其他代码的所有内容吗?
- 以下是让我困惑的例子 - >我的书中有这一部分说明:
"......该图将C++ 2008代码与传统C和本机C++代码结合在一起.它还提供了最常用于C++ 2008的两个程序集参考文件及其相关的命名空间.与使用Visual Studio开发时不同在编写单个源文件时,默认情况下不包含程序集引用文件.因此,必须为这些文件编写#using指令...."
#include <stdio.h>
#include <iostream>
#using <system.dll>
#using <system.windows.forms.dll>
// Associated namespace directives
using namespace std;
using namespace System;
using namespace System::Windows::Forms;
void main()
{
printf( "Hello, Earth\n"); // from stdio.h
cout << "Hello, Mars\n"; // from iostream
Console::WriteLine("Hello, Jupiter"); // from system.dll
MessageBox::Show ("Hello, Saturn"); // from system.windows.forms.dll
}
Run Code Online (Sandbox Code Playgroud) 我对 Objective-C 中的“接收器”是什么感到困惑?
在以下站点上,关于接收器的内容如下:https : //quizlet.com/104540068/objective-c-flash-cards/
“在 Objective-C 中,您可以通过将消息表达式括在括号中来指定对象(称为方法的接收者)和发送到该对象的消息。”
我不明白这个。我对目标 C 很陌生。感谢任何帮助。谢谢。
我试图System.Windows.SystemParameters.PrimaryScreenWidth绑定到ColumnDefinition的(从"网格"内)Width属性,并使用转换器将"PrimaryScreenWidth"转换成"GridLength".但它永远不会进入'转换'代码.
这是我的XAML:
<Window.Resources>
<local:ScreenWidthToLeftBarWidth x:Key="leftBarConverter" />
</Window.Resources>
<ColumnDefinition Width="{Binding ElementName=System.Windows.SystemParameters, Path=PrimaryScreenWidth, Converter={StaticResource leftBarConverter}}"/>
Run Code Online (Sandbox Code Playgroud)
这是转换器的CodeBehind(省略'ConvertBack'方法:
public class ScreenWidthToLeftBarWidth : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double aValue = (double)value;
GridLength newWidth = new GridLength(aValue);
return (newWidth);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我已经能够在稍微不同的情况下成功绑定使用'Button'对象Width并通过转换器运行它所以我认为问题在于我是如何尝试从"ElementName"绑定的= System.Windows.SystemParameters".任何帮助表示感谢,谢谢.
我希望能够创建一个函数,在其中指定一个参数以同时具有该容器的模板化容器和模板化元素类型。这可能吗?我收到“错误C2988:无法识别的模板声明/定义”。这是有问题的功能。
template<class Iter, class Elem>
void readIntoP(Iter<Elem> aCont){
ifstream ifss("data.dat");
string aString;
int counter = 0;
item tempItem;
while(ifss >> aString){
istringstream iss(aString);
if(counter == 0){
tempItem.name = aString;
}else if(counter == 1){
int aNum = 0;
iss >> aNum;
tempItem.iid = aNum;
}else{
double aNum = 0;
iss >> aNum;
tempItem.value = aNum;
aCont.push_back(tempItem);
counter = -1;
}
++counter;
}
}
Run Code Online (Sandbox Code Playgroud) assemblies ×1
c# ×1
c++ ×1
c++-cli ×1
command-line ×1
containers ×1
data-binding ×1
include ×1
java ×1
javac ×1
objective-c ×1
reference ×1
stl ×1
templates ×1
using ×1
wpf ×1
xaml ×1