我们假设我们有两个类,A并且B.
这是他们两个的代码
class A
{
public:
int x;
};
class B
{
public:
int y;
void FindY() { y = x + 12; }
};
void something()
{
A fs;
B fd;
fs.x = 10;
fd.FindY();
}
Run Code Online (Sandbox Code Playgroud)
问题是,我想访问x,但我不想传递任何东西作为我的功能的参数我看看朋友和继承,但两者似乎没有帮助我,纠正我,如果我错了.
一些我如何在功能中找到x FindY().
我要使用静态方法,但在我的情况下,我得到这个错误.
错误2错误LNK2001:未解析的外部符号"public:static class std::vector<class GUIDialog *,class std::allocator<class GUIDialog *> > Window::SubMenu" (?SubMenu@Window@@2V?$vector@PAVGUIDialog@@V?$allocator@PAVGUIDialog@@@std@@@std@@A) C:\Users\Owner\documents\visual studio 2010\Projects\Monopoly\Monopoly\Window.obj
以下是我如何声明它
static vector<GUIDialog *> SubMenu;
Run Code Online (Sandbox Code Playgroud)
由于这条线,我得到了那个错误
SubMenu.resize(3);
Run Code Online (Sandbox Code Playgroud) 我使用ASP.NET MVC 3和FluentValidation来验证我的视图模型.
我目前的文本框样式如下:
input[type="text"]{border:1px solid #c9d7e1;padding-left:2px;}
Run Code Online (Sandbox Code Playgroud)
如果输入有错误,我有一个验证器css类:
.input-validation-error{border:1px solid #ff0000;background-color:#ffeeee;}
Run Code Online (Sandbox Code Playgroud)
当验证开始时,文本框的背景颜色是#ffeeee,这是正确的,但它不会使文本框的边框变为红色(#ff0000).它仍然是#c9d7e1.如何更改样式以使文本框的边框变为红色?
我也将我的textareas定义为:
textarea{border:1px solid #c9d7e1;padding-left:2px;}
Run Code Online (Sandbox Code Playgroud)
并且边框设置为红色.
我可以在Qt样式表中自定义Qt应用程序的控件.但是,我找不到自定义标题栏的方法.我找到了一些解决方案,但这需要修改应用程序本身的代码.无论如何你可以使用Qt样式表来定制它吗?
我之前对阴影的印象是,它已经完成了已经有阴影的图像.直到我发现你可以使用普通的CSS创建阴影.如何在Qt样式表中创建阴影?
我试图通过多对多关系过滤一堆对象.因为trigger_roles字段可能包含多个条目,所以我尝试了包含过滤器.但是因为它被设计为与字符串一起使用,我几乎无能为力地过滤这种关系(你可以忽略values_list()atm.).
此功能附加到用户配置文件:
def getVisiblePackages(self):
visiblePackages = {}
for product in self.products.all():
moduleDict = {}
for module in product.module_set.all():
pkgList = []
involvedStatus = module.workflow_set.filter(trigger_roles__contains=self.role.id,allowed=True).values_list('current_state', flat=True)
Run Code Online (Sandbox Code Playgroud)
我的工作流模型看起来像这样(简化):
class Workflow(models.Model):
module = models.ForeignKey(Module)
current_state = models.ForeignKey(Status)
next_state = models.ForeignKey(Status)
allowed = models.BooleanField(default=False)
involved_roles = models.ManyToManyField(Role, blank=True, null=True)
trigger_roles = models.ManyToManyField(Role, blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)
虽然解决方案可能很简单,但我的大脑不会告诉我.
谢谢你的帮助.
我正在尝试创建一个System.Console.ReadLine()带有字符串参数的方法的重载.我的意图基本上是能够写作
string s = Console.ReadLine("Please enter a number: ");
Run Code Online (Sandbox Code Playgroud)
代替
Console.Write("Please enter a number: ");
string s = Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
我不认为有可能重载Console.ReadLine自己,所以我尝试实现一个继承的类,如下所示:
public static class MyConsole : System.Console
{
public static string ReadLine(string s)
{
Write(s);
return ReadLine();
}
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为它不可能继承System.Console(因为它是一个自动生成的静态类是一个密封的类).
我想在这里做什么才有意义?或者想要从静态类中重载某些东西永远不是一个好主意?
我有以下数组:
Array
(
[userid] => 1
[alias] => rahul
[firstname] => rahul
[lastname] => Khan2
[password] => Ý2jr™``¢(E]_Ø=^
[email] => salman@gmail.com
[url] => 4cfe07dbf35d6.jpg
[avatar_url] => 4cfe07efd2e1c.jpg
[thumb] => 4cfe07ebc8955.jpg
[crop_url] => 4cfe07dbf35d6.jpg
[crop_position] => [100,100,200,200]
[updatedon] => 0000-00-00 00:00:00
[createdon] => 0000-00-00 00:00:00
)
Run Code Online (Sandbox Code Playgroud)
我想删除元素url和crop_url我如何从数组中删除它们.
如何确定字符串是否已在C#中以编程方式编码?
让我们举例如字符串:
<p>test</p>
Run Code Online (Sandbox Code Playgroud)
我想让我的逻辑理解它已被编码的这个值..任何想法?谢谢
所以我有这个程序使用短链接获取页面(我使用谷歌网址缩短器).为了构建我的示例,我使用了C#中使用WebClient的代码,有没有办法在重定向后获取站点的URL?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MyWebClient client = new MyWebClient();
client.OpenRead("http://tinyurl.com/345yj7x");
Uri uri = client.ResponseUri;
Console.WriteLine(uri.AbsoluteUri);
Console.Read();
}
}
class MyWebClient : WebClient
{
Uri _responseUri;
public Uri ResponseUri
{
get { return _responseUri; }
}
protected override WebResponse GetWebResponse(WebRequest request)
{
WebResponse response = base.GetWebResponse(request);
_responseUri = response.ResponseUri;
return response;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不明白一件事:当我这样做时,client.OpenRead("http://tinyurl.com/345yj7x");下载网址指向的页面?如果这个方法下载页面,我需要一些东西才能得到我的网址,所以如果有方法只获取一些标题,或只有网址,请告诉我.
我必须将事件处理程序附加到表单上.如果不满足条件,第一个触发的应该停止另一个事件.
下面的代码不起作用,因为两个事件都将被触发.你能帮助我吗?
谢谢!
//fires first
$("#myform").submit(function(){
if (some validation) {
alert("You need to make the form valid");
return false;
}
});
//fires second
$("#myform").submit(function(){
//ajax stuff
return false;
});
Run Code Online (Sandbox Code Playgroud)
ps我必须这样,因为ajax的东西是在一个不可更改的插件中.我无法避免两个事件处理程序
c# ×3
c++ ×3
stylesheet ×3
qt ×2
arrays ×1
asp.net ×1
class ×1
console ×1
css ×1
django ×1
django-orm ×1
javascript ×1
jquery ×1
many-to-many ×1
overloading ×1
php ×1
python ×1
static ×1
visual-c++ ×1
webclient ×1