我尝试使用以下代码将新的.cpp文件添加到Visual Studio中的C项目中:
select
t1.id,
t1.strength,
t1.agility,
group_concat(t2.skill,',') bonuses
from table1 t1
left outer join
table2 t2
on t1.id = t2.id
where t1.id = 8
group by
t1.id,
t1.strength,
t1.agility;
然而, import UIKit
class ViewController: UIViewController,UIScrollViewDelegate {
let scrollView = UIScrollView(frame: CGRectMake(0, 0, 320, 300))
var colors:[UIColor] = [UIColor.redColor(), UIColor.blueColor(), UIColor.greenColor(), UIColor.yellowColor()]
var frame: CGRect = CGRectMake(0, 0, 0, 0)
var pageControl : UIPageControl = UIPageControl(frame: CGRectMake(50, 300, 200, 50))
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
configurePageControl()
scrollView.delegate = self
self.view.addSubview(scrollView)
for index in 0..<4 {
frame.origin.x = self.scrollView.frame.size.width * CGFloat(index)
frame.size = self.scrollView.frame.size
self.scrollView.pagingEnabled = true
var subView = UIView(frame: frame)
subView.backgroundColor = colors[index]
self.scrollView .addSubview(subView)
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * 4, self.scrollView.frame.size.height)
pageControl.addTarget(self, action: Selector("changePage:"), forControlEvents: UIControlEvents.ValueChanged)
}
func configurePageControl() {
// The total number of pages that are available is based on how many available colors we have.
self.pageControl.numberOfPages = colors.count
self.pageControl.currentPage = 0
self.pageControl.tintColor = UIColor.redColor()
self.pageControl.pageIndicatorTintColor = UIColor.blackColor()
self.pageControl.currentPageIndicatorTintColor = UIColor.greenColor()
self.view.addSubview(pageControl)
}
// MARK : TO CHANGE WHILE CLICKING ON PAGE CONTROL
func changePage(sender: AnyObject) -> () {
let x = CGFloat(pageControl.currentPage) * scrollView.frame.size.width
scrollView.setContentOffset(CGPointMake(x, 0), animated: true)
}
func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
let pageNumber = round(scrollView.contentOffset.x / scrollView.frame.size.width)
pageControl.currentPage = Int(pageNumber)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
单独产生了100多个错误,因此我不得不对此进行评论以确定是否存在问题。执行此操作后,会弹出此新错误:#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
cout << "Hello World!" << endl;
return 0;
}
。我猜这是因为项目是以某种方式为C配置的,或者是因为预处理器有一些我不知道的事情。我怎么解决这个问题?
答案 0 :(得分:1)
我尝试将新的.cpp文件添加到Visual Studio
中的C项目中
所以你知道它是C项目中的C ++代码。你知道C和C ++之间的区别是什么吗?如果是这样,您应该知道C没有using namespace
或<iostream>
,或<<
运算符或cout
。
如果您希望C ++文件在C项目中工作,您可以将项目配置为编译为C ++,将C ++文件转换为C代码,或者只是确保所有C ++文件都具有{{1} } extension(仅在C项目处于默认设置时才有效)。