我正在使用gcc(cygwin),gnu make,windows 7和cmake.
我的cmake testprojekt具有以下结构
rootdir
|-- App
| |-- app.cpp
| +-- CMakeLists.txt
|-- Lib
| |-- lib.cpp
| |-- CMakeLists.txt
|-- MakeFileProject
+ CMakeLists.txt
Run Code Online (Sandbox Code Playgroud)
ROOTDIR /应用/ app.cpp:
#include<string>
void printThemMessageToScreen(std::string input);//prototype
int main(int argc,char **argv){
printThemMessageToScreen("this will be displayed by our lib");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
ROOTDIR /库/ lib.cpp:
#include<iostream>
#include<string>
void printThemMessageToScreen(std::string input){
std::cout<<input;
}
Run Code Online (Sandbox Code Playgroud)
ROOTDIR /的CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
project(TestProject)
add_subdirectory(App)
add_subdirectory(Lib)
Run Code Online (Sandbox Code Playgroud)
ROOTDIR/lib中/的CMakeLists.txt:
add_library(Lib SHARED lib.cpp)
Run Code Online (Sandbox Code Playgroud)
ROOTDIR /应用/的CMakeLists.txt:
# Make sure the compiler can find include files from …Run Code Online (Sandbox Code Playgroud) 我正在努力学习Redux.我按照在线教程并使用他们的示例,它工作正常.然后我做了另一个小测试应用程序,它工作正常.现在我正在尝试另一个小测试应用程序,我坚持这个错误,不知道为什么.
该应用程序只是一个输入框和一个按钮,当您单击该按钮时,它会将框中的内容添加到下面显示的列表中.
但是,reducer不会更新状态.我已经看过造成这种情况的常见问题,似乎无法找到我的错误,我的减速器不会改变状态,我已经限制了调度等等.也许我只是在某个地方拼错了某些东西(或者像那样小而愚蠢的东西),但我无法让它发挥作用.
因此我尝试更改它,以便它只显示您在下面的框中输入的内容,并且它仍然无法正常工作.任何人都知道为什么减速器没有激活?
index.js(主要)
import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
import thunk from 'redux-thunk';
import promise from 'redux-promise';
import createLogger from 'redux-logger';
import allReducers from './reducers';
import App from './components/App';
const logger = createLogger();
const store = createStore(
allReducers,
applyMiddleware(thunk, promise, logger)
);
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud)
App.js
import React from 'react';
import NameList from '../containers/name-list.js'
import Input from '../containers/input.js'
const …Run Code Online (Sandbox Code Playgroud) 假设以下程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
namespace Lambda {
class Program {
public void TheFunction<T> (Expression<Func<T>> action) {
/** logic **/
}
static void Main (string[] args) {
TheFunction(); //this will of course not compile,
// because the Lambda Expression is missing.
}
}
public class foo {
public int bar { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是如何调用TheFunction?目标是使用Expression>,以便在TheFunction中检索除其他内容之外的属性名称.
我想要这样的东西:
//...
TheFunction((foo f)=> f.bar);
//...
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试它会说,类型参数不能从使用中产生,我应该尝试指定它们,但如何?