如何使用头文件中声明和定义的命名空间?

时间:2016-01-26 09:32:57

标签: namespaces

我有一个头文件和一个源文件

Header.h

<?php

namespace Application\Services;

use \Application\Entities\Keywords;

/**
 * Generated by PHPUnit_SkeletonGenerator on 2015-09-18 at 10:24:22.
 */
class DeviationTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @var Deviation
     */
    protected $object;
    protected $keyword;

    protected function setUp() {
        global $di;

        $this->object    = new Deviation($di);
        $this->keyword   = Keywords::findFirst('enabled = true AND text = "biura podróży"');
    }

    protected function tearDown() {

    }

    public function testGetDI() {
        $this->object->getDI();
    }

    public function testGet() {


        $this->object->get($this->keyword);
        $this->object->get($this->keyword, date('Y-m-d', strtotime('-1 day')));
        $this->object->get($this->keyword, date('Y-m-d'));

        return $this->object;
    }

    public function testGetOnDate() {

        $result = $this->object->get($this->keyword, date('Y-m-d', strtotime('-1 day')));
        print_r($result);

    }

    /**
     * @depends testGet
     */
    public function testCache($object) {

        $result = $object->get($this->keyword, date('Y-m-d', strtotime('-1 day')));
        $result = $object->get($this->keyword, date('Y-m-d', strtotime('-1 day')));
        $result = $object->get($this->keyword, date('Y-m-d', strtotime('-1 day')));

    }

}

Source.cpp

namespace na{

int gu = 25;
}

Basics.cpp

#include "stdafx.h"

int b = 10;

它会抛出以下错误:

  

具有此名称的命名空间不存在

1 个答案:

答案 0 :(得分:0)

添加Header.h解决了问题