标签: base

C++基本转换

您好我正在尝试将一些代码从Windows移植到Linux.我有这个:

itoa(word,aux,2);
Run Code Online (Sandbox Code Playgroud)

但GCC不承认itoa.如何在C++方式上转换为base 2?

谢谢 ;)

c++ base

5
推荐指数
1
解决办法
4592
查看次数

在引用CSS文件时,IE不支持基本元素中的相对路径

我有一个站点,使用基本标记来设置相对URL的绝对路径.它在我测试过的所有浏览器中都能正常工作,除了IE(大惊喜).根据IE为CSS文件提出的请求,似乎没有注意到基本标记.它确实使用页面上的其他内容来确认基本标记.为什么会这样?除了使用绝对路径引用CSS文件之外,还能做些什么吗?这是我的代码:

<!DOCTYPE html>
<html><head>
<title>base test</title>
<base href="/baseTest/">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div>foo</div>
</body></html>
Run Code Online (Sandbox Code Playgroud)

这是baseTest/style.css文件中的内容:

div {
    background: yellow;
}
Run Code Online (Sandbox Code Playgroud)

编辑:同样的事情似乎也发生在图像上.我做的所有测试都是在IE9中进行的.标准模式以及IE8和IE7兼容模式出现了问题.

编辑2:如果我指定绝对URL,它工作正常.我不知道对相对URL的支持是最近的功能.我可能会放弃我的计划使用基本标记来避免重复路径,除非我能找到一些方法(比如可能是JS hack)来完成这项工作.

示例页面:http://www.debugtheweb.com/test/base/relative.html

html css internet-explorer base internet-explorer-9

5
推荐指数
1
解决办法
2万
查看次数

大型抽象基类

我正在编写一个大型抽象基类,其中包含30个纯虚拟方法*.

查找在实现类中的基类中实现的所有函数有点单调乏味,主要是因为MSVC++没有告诉您哪个函数无法实现编译器错误"无法构造抽象类"

所以,我想知道我的大型抽象基类是一个坏主意,还是我应该把它拆分成几个接口,或者是否有编译器警告我可以激活它会告诉我哪种方法我没有提供实现.或者这只是抽象类编码的一部分,我应该习惯它.

*它的作用是在几个不同的渲染子系统之间提供一层通用功能.

c++ class base abstract visual-c++

5
推荐指数
1
解决办法
286
查看次数

生成一个带有参数的构造函数,并使用TypeBuilder调用base(argument)

我试图动态创建一个空构造函数,它接受一个参数,并使用TypeBuilder简单地调用base(参数).

我的代码是这样的:

(...)
// Create a class derived from this class
TypeBuilder typeBuilder = moduleBuilder.DefineType("NewClass", TypeAttributes.Class, this.GetType());    
ConstructorInfo baseCtor = this.GetType().GetConstructor(new[] { typeof(int) });

// Define new ctor taking int
ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public,  CallingConventions.Standard, new[] { typeof(int) });

// Generate code to call base ctor passing int
ILGenerator ctorIL = constructorBuilder.GetILGenerator();
ctorIL.Emit(OpCodes.Ldarg_0);
ctorIL.Emit(OpCodes.Ldarg_1);
ctorIL.Emit(OpCodes.Call, baseCtor);
ctorIL.Emit(OpCodes.Ret);

// Generate derived class
Type type = typeBuilder.CreateType();

// Try to instantiate using new constructor 
ConstructorInfo ctor = type.GetConstructor(new[] { typeof(int) });
object …
Run Code Online (Sandbox Code Playgroud)

c# constructor reflection.emit base typebuilder

5
推荐指数
0
解决办法
2185
查看次数

如何让IE支持html基本标签与相对href?喜欢:`<base href ="../"> </ base>`

我根据规格知道,hrefbase应该是一个绝对URI.

href = uri [CT]
This attribute specifies an absolute URI that acts as the base URI for resolving relative URIs.
Run Code Online (Sandbox Code Playgroud)

但是firefox和chrome支持相对URI,例如../../,这对我当前的项目非常重要.对于我的项目,除了"relative base href"之外,我找不到更好的解决方案.

IE是否有任何黑客或工作场所让它支持相对URI?我的网页现在在firefox和chrome中运行良好,但它必须支持IE.

internet-explorer base relative-path

5
推荐指数
1
解决办法
5334
查看次数

如何通过基类指针调用派生类的虚函数

我们来看看这段代码:

class CBase
{
 public:
    virtual vfunc() { cout << "CBase::vfunc()" << endl; }
};

class CChild: public CBase
{
 public:
    vfunc() { cout << "CChild::vfunc()" << endl; }
};

int main() 
{
 CBase *pBase = new CBase;
 ((CChild*)pBase)->vfunc(); // !!! important 
 delete pBase;
 return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是:

CBase::vfunc()
Run Code Online (Sandbox Code Playgroud)

但我想看看:CChild :: vfunc()

显式((CChild*)pBase)强制转换为"CChild*".那么为什么调用派生的vfunc()我需要用以下代码替换"important"字符串:((CChild*)pBase) - > CChild :: vfunc();

c++ virtual inheritance pointers base

5
推荐指数
2
解决办法
4090
查看次数

用于管理员的Rails基本控制器

我从.net迁移到rails并且我是初学者.我玩过但不知道如何为admin命名空间创建一个基本控制器来共享一些功能.我的意思是,在哪里放基类,因为我每次尝试都会出错.

谢谢

controller ruby-on-rails admin base

5
推荐指数
1
解决办法
2664
查看次数

C#不能覆盖继承的成员

我正在从一本名为Chegwidden Gladdis的书中学习C#.我正在制作与书中所写相同的程序和相同的代码.但有一个问题.我无法覆盖父类的方法.我从章节的开头就已经完全重读了这本书,5次,每次都是相同但是我无法弄清楚为什么我不能从父类中覆盖一个方法.这是基类PassFailActivity.cs中的代码

using System;
namespace ProtectedMembers
{
    public class PassFailActivity : GradedActivity2
    {
        private double minPassingScore; // Minimum passing score

        /// <summary>
        /// The constructor sets the minimum passing score
        /// </summary>
        /// <param name="mps">The minimum passing score.</param>
        public PassFailActivity(double mps)
        {
            minPassingScore = mps;
        }

        /// <summary>
        /// The GetGrade method returns a letter grade determined
        /// from the score field. This methos overrides the base class method.
        /// </summary>
        /// <returns>The letter grade</returns>
        public override char GetGrade()
        { …
Run Code Online (Sandbox Code Playgroud)

c# inheritance base object

5
推荐指数
1
解决办法
1万
查看次数

通过强制转换来覆盖重写方法

我有一个从A公开继承的B级:

class A {
    private:
    virtual void method();
}

class B : public A {
    private:
    void method();
}
Run Code Online (Sandbox Code Playgroud)

现在,我需要以某种方式调用原来的A::method()B::method(),而无需调用为A的拷贝构造函数
在图书馆,我想扩展定义A,所以我不能改变这个代码(使法保护的例子).是否有可能以某种方式将thisptr 投射B::method()到被覆盖的内部并切掉method

我正在使用一个调用的外部接口A::method().这个接口正确调用我的重写B::method(),但我似乎无法使接口调用内部B::method()不生成堆栈溢出.

c++ virtual casting base derived-class

5
推荐指数
1
解决办法
116
查看次数

在Excel中将HEX转换为RGB

我有一列"HEX"和三列"R","G"和"B".

如何将HEX转换为RGB(例如ff0000到R = 255,G = 0和B = 0)?

我知道前2个字符"ff"属于"R",下一个2"00"属于"G",最后2个"00"属于"B".

所以我将不得不使用ff0000"R" R=255,和G=0最后一个.

但是,我怎么能转换B=0ff0000等?我想我必须做一些事情从十六进制(基数16)解析到十进制(基数10)?

我想在没有VBA的情况下这样做.

excel hex base excel-formula excel-2010

5
推荐指数
2
解决办法
1万
查看次数